Skip to content

Latest commit

 

History

History
29 lines (27 loc) · 568 Bytes

SwooleCoroutinegetuid.md

File metadata and controls

29 lines (27 loc) · 568 Bytes

Swoole\Coroutine::getuid

获取当前协程的ID。函数原型

int function Swoole\Coroutine::getuid();

协程task的结构是:

struct _coro_task
{
    int cid; //协程ID
    /**
     * user coroutine
     */
    zval *function;
    time_t start_time;
    void (*post_callback)(void *param);
    void *post_callback_params;
};
  • 返回当前协程ID,是一个由0增长的长整型。
Swoole\Coroutine::create(function(){
    echo Swoole\Coroutine::getuid();
    echo "\n";
    echo swoole_async_dns_lookup_coro('www.baidu.com');
});