本文整理汇总了PHP中event_free函数的典型用法代码示例。如果您正苦于以下问题:PHP event_free函数的具体用法?PHP event_free怎么用?PHP event_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了event_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: close
/**
* 关闭socket
* @param $socket
* @param $event
* @return unknown_type
*/
static function close($socket, $event = null)
{
if ($event) {
event_del($event);
event_free($event);
}
fclose($socket);
}
示例2: __destruct
/**
* Free from loop
*/
public function __destruct()
{
if (!empty($this->event)) {
event_del($this->event);
event_free($this->event);
unset($this->event);
}
}
示例3: removeStream
public function removeStream($stream)
{
if (isset($this->events[(int) $stream])) {
$event = $this->events[(int) $stream];
event_del($event);
event_free($event);
unset($this->events[(int) $stream]);
}
}
示例4: free
public function free()
{
if (is_resource($this->ev)) {
event_del($this->ev);
event_free($this->ev);
}
if (isset($this->conn)) {
$this->conn->freeRequest($this);
}
}
示例5: close
public function close()
{
$this->log("close()");
foreach (array_keys($this->clients) as $id) {
$this->disconnectClient($id);
}
$this->clients = array();
stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR);
event_del($this->socket_event);
event_free($this->socket_event);
$this->socket_event = null;
}
示例6: service
private function service($connection, $flag, $base)
{
$connectionId = $this->getIdByConnection($connection);
$buffer = event_buffer_new($connection, array($this, 'onRead'), array($this, 'onWrite'), array($this, 'onError'), $connectionId);
event_buffer_base_set($buffer, $this->base);
event_buffer_watermark_set($buffer, EV_READ, 0, 0xffffff);
event_buffer_priority_set($buffer, 10);
event_buffer_enable($buffer, EV_READ | EV_WRITE | EV_PERSIST);
$this->buffers[$connectionId] = $buffer;
event_del($this->events[$connectionId]);
event_free($this->events[$connectionId]);
unset($this->events[$connectionId]);
}
示例7: onRequest
public function onRequest($clientSocket, $events, $arg)
{
try {
//$transport = new TBufferedTransport(new TNonblockingSocket($clientSocket));
$transport = new TNonblockingSocket($clientSocket);
call_user_func($this->callback, $transport);
} catch (Exception $e) {
\event_del($arg[0]);
\event_free($arg[0]);
// close socket
@stream_socket_shutdown($clientSocket, STREAM_SHUT_RDWR);
@fclose($clientSocket);
return;
}
}
示例8: __destruct
/**
* Free from loop and close the stream
*/
public function __destruct()
{
if (!empty($this->ev_read)) {
event_del($this->ev_read);
event_free($this->ev_read);
unset($this->ev_read);
}
if (!empty($this->ev_write)) {
event_del($this->ev_write);
event_free($this->ev_write);
unset($this->ev_write);
}
if (!empty($this->stream)) {
fclose($this->stream);
unset($this->stream);
}
}
示例9: removeStream
public function removeStream($stream)
{
$id = (int) $stream;
if (isset($this->events[$id])) {
$event = $this->events[$id];
unset($this->events[$id], $this->flags[$id], $this->readCallbacks[$id], $this->writeCallbacks[$id]);
event_del($event);
event_free($event);
}
}
示例10: remove
/**
* Unregister a stream
*
* @param resource $stream
* @param integer $type
* @return this
*/
public function remove($stream, $type = null)
{
$i = (int) $stream;
$type = is_null($type) ? array(self::READ, self::WRITE) : array($type);
// using libevent
if ($this->evbase) {
foreach ($type as $t) {
if (isset($this->streams[$t])) {
event_del($this->streams[$t][$i]);
event_free($this->streams[$t][$i]);
}
}
} else {
foreach ($type as $t) {
unset($this->streams[$t][$i], $this->handlers[$t][$i]);
}
}
return $this;
}
示例11: disable
/**
* Disable all events of sockets
* @return void
*/
public function disable()
{
return;
// possible critical bug
for (; sizeof($this->socketEvents);) {
if (!is_resource($ev = array_pop($this->socketEvents))) {
continue;
}
event_del($ev);
event_free($ev);
}
}
示例12: cancelTimer
/**
* {@inheritdoc}
*/
public function cancelTimer(TimerInterface $timer)
{
if ($this->isTimerActive($timer)) {
$event = $this->timerEvents[$timer];
event_del($event);
event_free($event);
$this->timerEvents->detach($timer);
}
}
示例13: _closeSocket
private function _closeSocket($socket, $event = null)
{
if ($event) {
\event_del($event);
\event_free($event);
}
\stream_socket_shutdown($socket, STREAM_SHUT_RDWR);
\fclose($socket);
}
示例14: destroy
/**
* Destroy event handle
*
* @return void
*/
private function destroy()
{
if ($this->handle) {
event_del($this->handle);
event_free($this->handle);
$this->handle = null;
}
}
示例15: __destruct
/**
* @codeCoverageIgnore
*/
public function __destruct()
{
foreach ($this->events as $event) {
event_free($event);
}
}