2

Are push and pop operations for arrays atomic? Can i safely run

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

in GIL-threaded env?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.