Flush all pending events.

@param  \Illuminate\Database\ConnectionInterface  $connection
@return void
323885
public function commit(ConnectionInterface $connection)
    {
        // We decrement the transaction level and prevent events to be dispatched
        // while comitting nested transactions, so no transient state is saved.
        // Only dispatch events right after the outer transaction commits.
        $this->transactionLevel--;
        if (! $this->isPrepared($connection) || $this->transactionLevel > 0) {
            return;
        }

        $this->dispatchPendingEvents($connection);
    }
420054
private function saveMigration(Connection $connection, string $class): void
    {
        $format = $connection->getSchemaManager()->getDatabasePlatform()->getDateTimeFormatString();
        $now    = (new DateTimeImmutable())->format($format);
        $connection->insert(static::MIGRATIONS_TABLE, [
            static::MIGRATIONS_COLUMN_CLASS       => $class,
            static::MIGRATIONS_COLUMN_MIGRATED_AT => $now,
        ]);
    }
258875
protected function releaseConnection(Connection $connection): void
    {
        $ip = $connection->getIp();

        if (!$ip) {
            $this->logger->warning('Cannot release connection');
            return;
        }

        if (!isset($this->ips[$ip])) {
            $this->ips[$ip] = 0;
        } else {
            $this->ips[$ip] = max(0, $this->ips[$ip] - 1);
        }

        unset($this->requests[$connection->getId()]);
    }
733217
public function handle(ConnectionInterface $incoming)
    {
        $this->incoming = $incoming;

        $this->incoming->on('data', [$this, 'handleData']);
        $this->incoming->on('close', function () {
            $this->connectionOpen = false;
        });

        $this->start = microtime(true);
        $this->requestSentAt = microtime(true);
        $this->getNextSlave();

        if ($this->maxExecutionTime > 0) {
            $this->maxExecutionTimer = $this->loop->addTimer($this->maxExecutionTime, [$this, 'maxExecutionTimeExceeded']);
        }
    }
223147
@Override
    public synchronized void flush() throws DatabaseEngineException {
        /*
         * Reconnect on this method does not make sense since a new connection will have nothing to flush.
         */

        try {
            for (MappedEntity me : entities.values()) {
                me.getInsert().executeBatch();
            }
        } catch (final Exception ex) {
            throw new DatabaseEngineException("Something went wrong while flushing", ex);
        }
    }
1023931
public function flush()
    {
        parent::flush();

        $this->middleware = [];
        $this->currentRoute = [];
        $this->loadedProviders = [];
        $this->routeMiddleware = [];
        $this->reboundCallbacks = [];
        $this->resolvingCallbacks = [];
        $this->availableBindings = [];
        $this->ranServiceBinders = [];
        $this->loadedConfigurations = [];
        $this->afterResolvingCallbacks = [];

        $this->router = null;
        $this->dispatcher = null;
        static::$instance = null;
    }
1345059
public function close(?string $connection = null): void
	{
		$connection = $connection ?? $this->default;

		if(isset($this->connections[$connection]))
		{
			if(method_exists($this->connections[$connection], 'close'))
			{
				// Call close on the connection object in case there's a reference
				// to the connection that won't be garbage collected immediately

				$this->connections[$connection]->close();
			}

			unset($this->connections[$connection]);
		}
	}
1203138
public function disconnect(Connection $connection = null) {
		if(!isset($connection)) {
			$this->connection->close();
		} else {
			$connection->close();
		}
	}
476982
public function removeConnection(Connection $connection): void
    {
        $socket = $connection->getSocket();

        if ($socket->getResource()) {
            $index = $socket->getResourceId();
        } else {
            $index = array_search($connection, $this->connections);
        }

        if (!$index) {
            $this->logger->warning('Could not remove connection: not found');
        }

        unset($this->connections[$index]);
        unset($this->resources[$index]);

        $this->server->notify(
            Server::EVENT_SOCKET_DISCONNECT,
            [$connection->getSocket(), $connection]
        );
    }
68753
protected function flushQueueItem(string $connectionName = null, MessageEnvelopeQueue $queue)
    {
        if ($queue->isEmpty()) {
            return;
        }
        $connection = $this->getConnectionHandler()->getConnection($connectionName);
        /* @var AndroidConnection $connection */
        foreach ($queue->getQueue() as $messageEnvelope) {
            /* @var AndroidMessageEnvelope $messageEnvelope */
            $this->sendMessageEnvelope($connection, $messageEnvelope);
        }
        $queue->clear();
    }
264850
protected static function _connection(& $connection)
	{
		if (static::isString($connection))
			$connection = static::connection($connection);

		if (!$connection instanceof \PDO)
			throw new \InvalidArgumentException("invalid connection");
	}
235591
public function flush()
    {
        $this->aliases = [];
        $this->resolved = [];
        $this->bindings = [];
        $this->instances = [];
        $this->abstractAliases = [];
    }
1048019
private void onCleanup(Object connection)
    {
        // if not running within transaction boundary
        if (this.connection != null)
        {
            if (settings != null)
            {
                ((Jedis) connection).configResetStat();
            }
            factory.releaseConnection((Jedis) this.connection);
        }

        this.connection = null;
    }
1294344
public function onWorkerConnect($connection)
    {
        $connection->maxSendBufferSize = $this->sendToWorkerBufferSize;
        $connection->authorized = $this->secretKey ? false : true;
    }
226813
protected function handle(ConnectionInterface $connection, Payload $payload)
    {
        switch ($payload->getEvent()) {
            case ConnectionEvent::SOCKET_AUTH_REQUEST:
                $this->handleAuthentication($connection, $payload);
                break;
            default:
                $this->eventDispatcher->dispatch($payload->getEvent(), new ConnectionEvent($connection, $payload));
                $this->logger->notice(sprintf('Dispatched event: %s', $payload->getEvent()));
        }
    }
89185
public function handle(EventInterface $event)
    {
        try {
            $this->getApplicationServer()->getSystemLogger()->info($event->getName());
        } catch (\Exception $e) {
             $this->getApplicationServer()->getSystemLogger()->error($e->__toString());
        }
    }
1172742
public function freeConnection($connection) {
		$this->connection->push($connection);
		if ($this->wait->count() > 0) {
			$uid = $this->wait->pop();
			co::resume($uid);
		} else {
			//有连接处于空闲状态超过15秒，关闭一个连接
			if ($this->connection_count > $this->getMinClient() && time() - $this->last_run_out_time > 15) {
				$this->close();
			}
		}
	}