Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenResty 线程 #84

Open
isshe opened this issue May 16, 2023 · 0 comments
Open

OpenResty 线程 #84

isshe opened this issue May 16, 2023 · 0 comments

Comments

@isshe
Copy link
Owner

isshe commented May 16, 2023

https://isshe.site/p/openresty-%E7%BA%BF%E7%A8%8B/

OpenResty 协程/线程 后续都称为协程。
通过前面的探索可以看出,ngx_http_lua_run_thread 是相当重要的一个函数,对于协程的调度,都是通过此接口进行。
目的:
了解 OpenResty 协程是什么? 是否和此函数强关联:ngx_http_lua_run_thread? OpenResty 的协程与 Luajit 的协程是什么关系? OpenResty 协程是如何创建的?是何时创建的?(排除前面探究过的轻线程和 coroutine 接口) OpenResty 协程会在何时执行?(排除前面探究过的轻线程和 coroutine 接口) 主协程和其他协程是如何区分的? Lua VM 和主协程是什么关系? 这里描述的协程与前面章节中描述的 coroutine 什么关系? 使用 不涉及
实现 协程的状态 typedef enum { NGX_HTTP_LUA_CO_RUNNING = 0, /* coroutine running / NGX_HTTP_LUA_CO_SUSPENDED = 1, / coroutine suspended / NGX_HTTP_LUA_CO_NORMAL = 2, / coroutine normal / NGX_HTTP_LUA_CO_DEAD = 3, / coroutine dead / NGX_HTTP_LUA_CO_ZOMBIE = 4, / coroutine zombie */ } ngx_http_lua_co_status_t; NGX_HTTP_LUA_CO_RUNNING:当前协程正在执行 NGX_HTTP_LUA_CO_SUSPENDED:当前协程已挂起,等待恢复 NGX_HTTP_LUA_CO_NORMAL:正常 NGX_HTTP_LUA_CO_DEAD:协程死亡/终止了 NGX_HTTP_LUA_CO_ZOMBIE:是僵尸协程,等待父协程回收 新建协程:ngx_http_lua_new_thread - ngx_http_lua_new_thread - ngx_http_get_module_main_conf:获取模块配置 - if (L == lmcf->lua && !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant