Closed huyuguang closed 7 years ago
@huyuguang Will you explain what business-level problems you are trying to solve? It's easier to tell us what you really want instead of how you want to implement something. What database are you talking to? Have you checked out our lua-resty-mysql and @leafo's pgmoon libraries?
@huyuguang I don't think this question belongs to this ngx_echo
module. It looks moe like an nginx development question. It's off topic. And I'm closing this.
I just found some hint from ngx source code. The function ngx_epoll_aio_init should be what I need.
Let me describe why I need the post_task. Some functions use too much system resource (for example, hmac(large_file)) or have only blocking version, so I need to create a single thread or thread pool to queue the function calls and execute them one by one.
Maybe it is a stupid question but I do can not find the answer everywhere.
For example, I have a function looks like query_db(sql, context, callback); The function create a worker thread to sync query db and call callback(context, result) in worker thread.
So I need a function looks like post_task_in_ngx_thread(context, function) so that I can run callback in correct thread (ngx thread).
How to implement it? How can I add a eventfd to epoll_wait?