开发者

ruby atomic operations in multithreaded environment

开发者_如何学PythonAre push and pop operations for arrays atomic? Can i safely run

i = array.pop
...
array.push(i)

in GIL-threaded env?


You can look in the c code (array.c) if it calls any ruby method calls (rb_funcall) then it's not thread safe, I believe. Otherwise it should be...

You could easily override #pop et al and make them have their own synchronization.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜