Vapm
  • About
    • Why is it called unblocking?
    • Next update?
    • Credit
    • Info
  • System
    • runEventLoop()
    • runSingleEventLoop()
    • setTimeout()
    • setInterval()
    • fetch()
    • read()
    • time() & timeEnd()
  • Asynchronous
    • getId()
    • await()
  • Promise
    • c()
    • getId()
    • getFiber()
    • isJustGetResult()
    • getTimeOut()
    • getTimeStart()
    • getTimeEnd()
    • setTimeEnd()
    • canDrop()
    • getStatus()
    • getResult()
    • getReturn()
    • getCallback()
    • resolve() & reject()
    • then() & catch() & finally()
    • useCallbacks()
    • all()
    • allSettled()
    • any()
    • race()
    • Some common methods
  • CoroutineGen
    • runBlocking()
    • runNonBlocking()
    • Deferred
    • Deferred Await All
    • repeat() & delay()
    • Channel
      • Example about Channel
    • AwaitGroup
      • Example
    • Mutex
      • Example
    • Goroutine vs CoroutineGen
      • Concurrency
  • Thread
    • How do I create a thread?
    • How do I share data between threads?
    • Advanced Thread
  • Worker
    • Example
  • Stream
    • read()
    • write()
    • append()
    • delete()
    • create()
    • overWrite()
  • FAQ
    • Why System::runEventLoop() and System::runSingleEventLoop() ?
    • Do you want concurrency?
  • PocketMine-PMMP
Powered by GitBook
On this page
  1. CoroutineGen

Channel

The Channel class is used to synchronize concurrent tasks from CoroutineGen.

Interface

 /**
  * @param mixed $message
  * @return Generator
  *
  * This function is used to send a message to the channel.
  */
 public function sendGen($message): Generator;

 /**
  * @param mixed $message
  * @return void
  *
  * This function is used to send a message to the channel.
  */
 public function send($message): void;

 /**
  * @param callable $callback
  * @return Generator
  *
  * This function is used to receive a message from the channel.
  */
 public function receiveGen(callable $callback): Generator;

 /**
  * @param callable $callback
  * @return void
  *
  * This function is used to receive a message from the channel.
  */
 public function receive(callable $callback): void;

 /**
  * @return bool
  *
  * This function is used to check if the channel is empty.
  */
 public function isEmpty(): bool;

 /**
  * @return void
  *
  * This function is used to close the channel.
  */
 public function close(): void;

 /**
  * @return bool
  *
  * This function is used to check if the channel is closed.
  */
 public function isClosed(): bool;
Previousrepeat() & delay()NextExample about Channel

Last updated 8 months ago