ruby - SizedQueue.clear does not free push -
The code below is a lot of simpler and complex code, what happens when I turn on the stop function and The queue was clear I was expecting the lock on get_new thread to free and instead of ending the whole thread, what happens to a dead lock on its thread.
Can you understand me if I pop up instead of clarifying the desired behavior? Class controller requires 'thread' 'monitor' requires 'net / http' attr_accessor: thread_count ,: event_queue ,: is_running ,: producer_thread ,: start events def @thread_count = 5 @event_queue = SizedQueue New (@thread_count) @events = [27242233, 27242232, 27242231] end def start @is_running = true @producer_thread = thread.nu {get_new ()} end def get_new while @is_running do @ events.each do | E P e.to_s @event_queue & lt; & Lt; E end sleeping 1 end P "thread finish" end def stop p "stop!" @ Event_queue.clear p "Qi Size:" + @ event_queue.length.to_s Sleep 2 @is_running = False sleep 2 producer_read.joined "Done!" End and Service = Controller. New Service. Start Sleep 5 Service. Stop
It was one in Ruby that is fixed in Ruby.
Earlier versions of Ruby 2.1 and 2.0 were also affected. For people you want 2.1.2 or 2.0.0p481 respectively
Comments
Post a Comment