Browse files

shutdown broadcast callback when we're done with it

  • Loading branch information...
1 parent 8f8f857 commit 8705f00194504ed4af6bd32f6d337321050ef6be @slyphon committed May 1, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/zk-group/group_base.rb
View
4 lib/zk-group/group_base.rb
@@ -59,6 +59,8 @@ def initialize(zk, name, opts={})
@known_members = []
@membership_subscriptions = []
+ # ThreadedCallback will queue calls to the block and deliver them one at a time
+ # on their own thread. This guarantees order and simplifies locking.
@broadcast_callback = ThreadedCallback.new { |event| broadcast_membership_change!(event) }
@membership_ev_sub = zk.register(path, :only => :child) do |event|
@@ -79,6 +81,8 @@ def close
return unless @created
@created = false
+ @broadcast_callback.shutdown
+
@on_connected_sub.unsubscribe
@membership_ev_sub.unsubscribe

0 comments on commit 8705f00

Please sign in to comment.