summaryrefslogtreecommitdiff
path: root/ngx_lua-0.10.28/src/ngx_http_lua_uthread.h
blob: 9c3e2d417399fa7b85dda4ff1d746a10eadc84f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * Copyright (C) Yichun Zhang (agentzh)
 */


#ifndef _NGX_HTTP_LUA_UTHREAD_H_INCLUDED_
#define _NGX_HTTP_LUA_UTHREAD_H_INCLUDED_


#include "ngx_http_lua_common.h"


#define ngx_http_lua_is_thread(ctx)                                          \
    ((ctx)->cur_co_ctx->is_uthread || (ctx)->cur_co_ctx == &(ctx)->entry_co_ctx)


#define ngx_http_lua_is_entry_thread(ctx)                                    \
    ((ctx)->cur_co_ctx == &(ctx)->entry_co_ctx)


#define ngx_http_lua_entry_thread_alive(ctx)                                 \
    ((ctx)->entry_co_ctx.co_ref != LUA_NOREF)


#define ngx_http_lua_coroutine_alive(coctx)                                  \
    ((coctx)->co_status != NGX_HTTP_LUA_CO_DEAD                              \
     && (coctx)->co_status != NGX_HTTP_LUA_CO_ZOMBIE)


void ngx_http_lua_inject_uthread_api(ngx_log_t *log, lua_State *L);


#endif /* _NGX_HTTP_LUA_UTHREAD_H_INCLUDED_ */

/* vi:set ft=c ts=4 sw=4 et fdm=marker: */