aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/server.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-06-17 12:48:53 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-06-17 12:48:53 +0100
commita2fc458d4c1bc6027760546653cb153e775576ce (patch)
treef3af3775adab48d9a18495eeb410cf48269ffd9e /lib/mauve/server.rb
parent4b39583e63b59d73e2855d776f7cca12d734f2af (diff)
* 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
Diffstat (limited to 'lib/mauve/server.rb')
-rw-r--r--lib/mauve/server.rb19
1 files changed, 12 insertions, 7 deletions
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