blocking ruby threads

S

snacktime

I've read a lot of bits and pieces in the past but maybe someone can
help me finalize my thoughts here or correct me where I am wrong.

From my understanding ruby threads will not block unless you are
calling out to a C extension which blocks, or in specific off the wall
case like needing to use resolve-replace so dns lookups don't block.
I understand it to be this way because the select loop that is used to
implement the threads will not do IO reads/writes unless there is data
that is ready.

Am I missing anything here? Are there other edge cases where ruby
threads would block?

Chris
 
R

Robert Klemme

I've read a lot of bits and pieces in the past but maybe someone can
help me finalize my thoughts here or correct me where I am wrong.

From my understanding ruby threads will not block unless you are
calling out to a C extension which blocks, or in specific off the wall
case like needing to use resolve-replace so dns lookups don't block.

That depends on how DNS lookups are implemented in Ruby. If a standard
library funtion is called then the interpreter might actually block.
I understand it to be this way because the select loop that is used to
implement the threads will not do IO reads/writes unless there is data
that is ready.

Am I missing anything here? Are there other edge cases where ruby
threads would block?

Not exactly an edge case but Ruby threads will block when trying to grab
a mutex or monitor that is hold by another thread.

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top