@param \Amp\Parallel\Sync\Channel $channel

@return \Generator

@codeCoverageIgnore Only executed in thread.
351587
private function execute(Channel $channel): \Generator
    {
        try {
            $result = new ExitSuccess(yield call($this->function, $channel, ...$this->args));
        } catch (\Throwable $exception) {
            $result = new ExitFailure($exception);
        }

        if ($this->killed) {
            return; // Parent is not listening for a result.
        }

        // Attempt to return the result.
        try {
            try {
                yield $channel->send($result);
            } catch (SerializationException $exception) {
                // Serializing the result failed. Send the reason why.
                yield $channel->send(new ExitFailure($exception));
            }
        } catch (ChannelException $exception) {
            // The result was not sendable! The parent context must have died or killed the context.
        }
    }
236652
public function detachCallback($channel)
    {
        $callbackName = $this->getPrefixKeys().$channel;

        if (isset($this->callbacks[$callbackName])) {
            unset($this->callbacks[$callbackName]);
            $this->pubsub->unsubscribe($channel);
        }
    }
1298683
public function createLogger($channel)
    {
        Cascade::loadConfigFromArray($this->config);
        $logger = Cascade::getLogger($channel);
        $logger->pushProcessor(new PsrLogMessageProcessor());
        return $logger;
    }
1052180
public function setChannel(\CampaignChain\CoreBundle\Entity\Channel $channel)
    {
        $this->channel = $channel;

        return $this;
    }
310549
public function channel($channel)
    {
        $channel = $this->client->get(config('twitch-api.api_url') . '/kraken/channels/' . $channel);

        return $channel->json();
    }
835630
public function switchChannel(Channel $channel)
    {
        $deferred = new Deferred();

        if ($channel->type != Channel::TYPE_VOICE) {
            $deferred->reject(new \InvalidArgumentException('Channel must be a voice chnanel to be able to switch'));

            return $deferred->promise();
        }

        $this->mainSend([
            'op' => Op::OP_VOICE_STATE_UPDATE,
            'd'  => [
                'guild_id'   => $channel->guild_id,
                'channel_id' => $channel->id,
                'self_mute'  => $this->mute,
                'self_deaf'  => $this->deaf,
            ],
        ]);

        $this->channel = $channel;

        $deferred->resolve();

        return $deferred->promise();
    }
135114
public function deleteChannel($channel)
    {
        $op = $this->sendDeleteChannelOperation($channel);

        // waiting for delete operation finishes
        $op = $this->awaitOperation($op);

        // true if succeeded
        return $op->getState() == OperationState::Succeeded;
    }
125955
public function sendStartChannelOperation($channel)
    {
        $channelId = Utilities::getEntityId(
            $channel,
            'WindowsAzure\MediaServices\Models\Channel'
        );
        $headers = [
            Resources::CONTENT_TYPE => Resources::JSON_CONTENT_TYPE,
        ];

        return $this->_sendOperation(
            null,
            "Channels('{$channelId}')/Start",
            Resources::HTTP_POST,
            Resources::STATUS_ACCEPTED,
            $headers);
    }
1224960
public function removeChannel($channel)
    {
        $channel = strtolower($channel);
        if (isset($this->channels)) {
            unset($this->channels[$channel]);
        }
        return $this;
    }
111699
public function addChannel($channel)
    {
        if ($channel instanceof ChannelInterface) {
            $channel = $channel->getId();
        }

        $channel = (string) $channel;

        if (false === array_search($channel, $this->channels)) {
            $this->channels[] = $channel;
        }

        return $this;
    }
136555
public function getChannel($channelId)
    {
        $uri = "channels/$channelId";
        try {
            $response = $this->client->getEndpoint()->get($uri);
        } catch (RequestException $e) {
            $this->processRequestException($e);
        }

        return new Channel($this->client, \GuzzleHttp\json_decode($response->getBody()));
    }
70859
final public function listen(string $channel): Promise
    {
        if (! $this->handle) {
            throw new FailureException('Not connected');
        }

        return $this->send("listen", $channel);
    }
902742
public function dispatchBatch($channel, array $events)
    {
        $messages = [];
        $validates = true;

        foreach ($events as $event) {
            /** @var EventInterface $event */
            $event = $this->prepEventForDispatch($event);

            if ($this->validator) {
                $result = $this->validator->validate($event);
                if ($result->fails()) {
                    $validates = false;

                    // pass to validation fail handler?
                    if ($this->validationFailHandler) {
                        call_user_func($this->validationFailHandler, $result);
                    }

                    if ($this->throwValidationExceptionsOnDispatch) {
                        throw new ValidationException($result);
                    }
                }
            }

            $messages[] = $event->toMessage();
        }

        if ($validates) {
            $this->adapter->publishBatch($channel, $messages);
        }
    }
774483
public function addChannel(\CampaignChain\CoreBundle\Entity\Channel $channels)
    {
        $this->channels[] = $channels;

        return $this;
    }
1074837
public function startChannel($channel)
    {
        $op = $this->sendStartChannelOperation($channel);

        // waiting for create operation finishes
        $op = $this->awaitOperation($op);

        // true if succeeded
        return $op->getState() == OperationState::Succeeded;
    }
1306809
public function publishBatch($channel, array $messages)
    {
        foreach ($messages as $message) {
            $this->publish($channel, $message);
        }
    }
507954
private synchronized void createChannel(String channel) {
        if (!channelExists(channel)) {
            Queue queue = new Queue(channel, true, false, true);
            admin.declareQueue(queue);
            Binding binding = new Binding(channel, DestinationType.QUEUE, exchange.getName(), channel + ".#", null);
            admin.declareBinding(binding);
        }
    }