swoole_process源码解析之对象析构

版权声明:转载请注明来源 https://blog.csdn.net/u013702678/article/details/82937288

swoole_process提供了__destruct方法,用于释放swoole内部对象资源,这个会在swoole_process对象释放时调用。

我们看下其流程。

static PHP_METHOD(swoole_process, __destruct)
{
    swWorker *process = swoole_get_object(getThis());//获取swoole内部对应的对象swWorker
    swPipe *_pipe = process->pipe_object;//获取对象管道信息
    if (_pipe)//管道不为空,则关闭管道和执行内存空间释放动作
    {
        _pipe->close(_pipe);
        efree(_pipe);
    }

    if (process->queue)//开启了消息队列
    {
        efree(process->queue);//释放消息队列空间
    }

    efree(process);//释放swWorker对象空间信息
}

猜你喜欢

转载自blog.csdn.net/u013702678/article/details/82937288
今日推荐