@@ -343,43 +343,44 @@ static VALUE worker_pool_call(VALUE self, VALUE _blocking_operation) {
343343 };
344344
345345 // Enqueue work:
346- pthread_mutex_lock (& pool -> mutex );
347- enqueue_work (pool , & work );
348- pthread_cond_signal (& pool -> work_available );
349- pthread_mutex_unlock (& pool -> mutex );
346+ // pthread_mutex_lock(&pool->mutex);
347+ // enqueue_work(pool, &work);
348+ rb_fiber_scheduler_blocking_operation_execute (work -> blocking_operation );
349+ // pthread_cond_signal(&pool->work_available);
350+ // pthread_mutex_unlock(&pool->mutex);
350351
351352 // Block the current fiber until work is completed:
352- int state = 0 ;
353- while (true) {
354- int current_state = 0 ;
355- rb_protect (worker_pool_work_begin , (VALUE )& work , & current_state );
356- if (DEBUG ) fprintf (stderr , "-- worker_pool_call:work completed=%d, current_state=%d, state=%d\n" , work .completed , current_state , state );
353+ // int state = 0;
354+ // while (true) {
355+ // int current_state = 0;
356+ // rb_protect(worker_pool_work_begin, (VALUE)&work, ¤t_state);
357+ // if (DEBUG) fprintf(stderr, "-- worker_pool_call:work completed=%d, current_state=%d, state=%d\n", work.completed, current_state, state);
357358
358- // Store the first exception state:
359- if (!state ) {
360- state = current_state ;
361- }
359+ // // Store the first exception state:
360+ // if (!state) {
361+ // state = current_state;
362+ // }
362363
363- // If the work is still in the queue, we must wait for a worker to complete it (even if cancelled):
364- if (work .completed ) {
365- // The work was completed, we can exit the loop:
366- break ;
367- } else {
368- if (DEBUG ) fprintf (stderr , "worker_pool_call:rb_fiber_scheduler_blocking_operation_cancel\n" );
369- // Ensure the blocking operation is cancelled:
370- rb_fiber_scheduler_blocking_operation_cancel (blocking_operation );
364+ // // If the work is still in the queue, we must wait for a worker to complete it (even if cancelled):
365+ // if (work.completed) {
366+ // // The work was completed, we can exit the loop:
367+ // break;
368+ // } else {
369+ // if (DEBUG) fprintf(stderr, "worker_pool_call:rb_fiber_scheduler_blocking_operation_cancel\n");
370+ // // Ensure the blocking operation is cancelled:
371+ // rb_fiber_scheduler_blocking_operation_cancel(blocking_operation);
371372
372- // The work was not completed, we need to wait for it to be completed, so we go around the loop again.
373- }
374- }
373+ // // The work was not completed, we need to wait for it to be completed, so we go around the loop again.
374+ // }
375+ // }
375376
376- if (DEBUG ) fprintf (stderr , "<- worker_pool_call:work completed=%d, state=%d\n" , work .completed , state );
377+ // if (DEBUG) fprintf(stderr, "<- worker_pool_call:work completed=%d, state=%d\n", work.completed, state);
377378
378- if (state ) {
379- rb_jump_tag (state );
380- } else {
379+ // if (state) {
380+ // rb_jump_tag(state);
381+ // } else {
381382 return Qtrue ;
382- }
383+ // }
383384}
384385
385386static VALUE worker_pool_allocate (VALUE klass ) {
0 commit comments