Fine grained management of timers.

S

snacktime

We have a rails app that does async requests to backend data stores.
We send up to 10 of these requests for every http request, and 2-3 ms
matters. I do have one thread that I spin up inside rails that wraps
a select() loop, and another loop that gets entered when a controller
is waiting for a response. In that second loop I use a call to
sleep(). Sleep seems really unpredictable, probably because of it's
interaction with the thread timers via ruby's scheduler. I've though
about using nanosleep via inline C, but even if that worked it would
probably block the thread causing worse problems.


So is this something that I just have to live with, or is there any
other way to get the equivalent of usleep/nanosleep?

Chris
 
J

jan.svitok

We have a rails app that does async requests to backend data stores.
We send up to 10 of these requests for every http request, and 2-3 ms
matters. I do have one thread that I spin up inside rails that wraps
a select() loop, and another loop that gets entered when a controller
is waiting for a response. In that second loop I use a call to
sleep(). Sleep seems really unpredictable, probably because of it's
interaction with the thread timers via ruby's scheduler. I've though
about using nanosleep via inline C, but even if that worked it would
probably block the thread causing worse problems.


So is this something that I just have to live with, or is there any
other way to get the equivalent of usleep/nanosleep?

Chris

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/249226
 

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,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top