mattn / mruby-uv

interface to libuv for mruby(experimental)
http://mattn.kaoriya.net/
92 stars 25 forks source link

Force cfunc in queue_work's work_cb and add test for it. #32

Closed take-cheeze closed 10 years ago

take-cheeze commented 10 years ago

This changes is to make API UV.queue_work more safer. Since uv_work_cb would be always runned on separate thread as mruby runs, running block on it will break running context of mruby. On new mruby-uv uv_work_cb, it can only run cfunc proc that can run separately with mrb_state that is passed to UV.queue_work as argument. (The cfunc would be called with arguments NULL, mrb_nil_value() and returned value would be discarded.) And the block passed to UV.queue_work would be runned on uv_after_work_cb. (See the test codes for detail. It will run summing of 0 to 99 on other thread.)

mattn commented 10 years ago

SGTM

mattn commented 10 years ago

Than you