mattn / mruby-thread

48 stars 31 forks source link

Support for other Thread structures #9

Open postmodern opened 10 years ago

postmodern commented 10 years ago

Would be useful if Queue, SizedQueue were also supported.

mattn commented 10 years ago

Mutex is already done. Right?

postmodern commented 10 years ago

Ah my mistake, Mutex is indeed there. Queue would definitely be useful for thread pools.

mattn commented 10 years ago

As same as reason I commented in another issue, mruby-thread is not green thread. So Queue may not be easy to implement.

postmodern commented 10 years ago

@mattn would implementing MRI 1.9 style pthread-based Thread / Mutex require adding a GIL to mruby?

mattn commented 10 years ago

mruby-thread is marshaling values between main thread's mrb_state and another thread's mrb_state.

https://github.com/mattn/mruby-thread/blob/master/src/mrb_thread.c#L65

So the proc which is generated in main thread doesn't work at another thread.

mattn commented 10 years ago

Is this closable? #7

postmodern commented 10 years ago

I think it's possible to implement Queue using pthread_mutex_lock and pthread_mutex_unlock.

mattn commented 10 years ago

As I said, mruby-thread is not green thread, So context is not shared. Even though you create Queue out side of thread, you can't manipulate it,