0
@@ -56,10 +56,28 @@ oneshot_timeout (struct ev_loop *loop, struct ev_timer *w, int revents) {;}
0
VALUE server_process_connections(VALUE _)
0
+ /* This function is super hacky. The libev loop is called for one iteration
0
+ * this means that any pending events are handled. If no events exist then
0
+ * the function blocks. We want blocking so that the while loop in ruby
0
+ * doesn't race away - however there is a need to continue to process other
0
+ * ruby threads which are running. While this function is being called
0
+ * other ruby threads cannot execute.
0
+ * So we set this timeout event which breaks the block after 0.1 seconds.
0
+ * Additionally we make sure that other threads get enough processing time
0
+ * by calling rb_thread_schedule() many times.
0
+ * Instead we should probably use rb_thread_select on server->fd when no
0
+ * clients are in_use? Whatever happens here, one should make sure the
0
+ * 'wait' benchmark is running as quickly with Ebb as it does with mongrel.
0
- ev_timer_init (&timeout, oneshot_timeout, 0.01, 0.);
0
+ ev_timer_init (&timeout, oneshot_timeout, 0.1, 0.);
0
ev_timer_start (loop, &timeout);
0
ev_loop(loop, EVLOOP_ONESHOT);
0
+ /* remove the timeout event so that it isn't called immediately the next
0
+ * time around (since 0.1 seconds will have passed)
0
ev_timer_stop(loop, &timeout);
0
/* Call rb_thread_schedule() proportional to the number of rb threads running */
Comments
No one has commented yet.