From a2fc458d4c1bc6027760546653cb153e775576ce Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Fri, 17 Jun 2011 12:48:53 +0100 Subject: * Notifications are now run in their separate threads. * Queues are now just arrays instead of "Queue"s * Updated templates to be saner. * Added flusing of queues when threads stop --- lib/mauve/server.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'lib/mauve/server.rb') diff --git a/lib/mauve/server.rb b/lib/mauve/server.rb index 2df3888..c985e15 100644 --- a/lib/mauve/server.rb +++ b/lib/mauve/server.rb @@ -53,8 +53,8 @@ module Mauve # Keep these queues here to prevent a crash in a subthread losing all the # subsquent things in the queue. # - @packet_buffer = Queue.new - @notification_buffer = Queue.new + @packet_buffer = [] + @notification_buffer = [] @config = DEFAULT_CONFIGURATION end @@ -115,13 +115,18 @@ module Mauve end def stop + if @stop + logger.debug("Stop already called!") + return + end + @stop = true thread_list = Thread.list thread_list.delete(Thread.current) - THREAD_CLASSES.reverse.each do |klass| + THREAD_CLASSES.each do |klass| thread_list.delete(klass.instance) klass.instance.stop unless klass.instance.nil? end @@ -209,11 +214,11 @@ module Mauve # These methods pop things on and off the packet_buffer # def packet_enq(a) - instance.packet_buffer.enq(a) + instance.packet_buffer.push(a) end def packet_deq - instance.packet_buffer.deq + instance.packet_buffer.shift end def packet_buffer_size @@ -227,11 +232,11 @@ module Mauve # These methods pop things on and off the notification_buffer # def notification_enq(a) - instance.notification_buffer.enq(a) + instance.notification_buffer.push(a) end def notification_deq - instance.notification_buffer.deq + instance.notification_buffer.shift end def notification_buffer_size -- cgit v1.2.1