public
Description: StrokeDB is an embeddable distributed document database written in Ruby
Homepage: http://strokedb.com/
Clone URL: git://github.com/yrashk/strokedb.git
added instant_queue
oleganza (author)
Thu Apr 24 15:28:15 -0700 2008
commit  d6a0a5d85b7e4bef0c425b399d949b7568e3d771
tree    49b98ef254592eb205f9e2f377aee5335320c275
parent  80a0fed3c86583b836e2a6a77979949b124dfd62
...
1
 
2
3
4
5
...
1
2
3
4
5
6
0
@@ -1,4 +1,5 @@
0
 require 'sync/diff'
0
+require 'sync/queues'
0
 require 'sync/chain_sync'
0
 require 'sync/store_sync'
0
 require 'sync/lamport_timestamp'
0
\ No newline at end of file
...
13
14
15
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
18
19
...
26
27
28
 
 
 
 
 
 
 
29
30
...
13
14
15
 
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
...
40
41
42
43
44
45
46
47
48
49
50
51
0
@@ -13,7 +13,21 @@ module StrokeDB
0
     # on_receive callback is called when the queue decides do pop
0
     # out an object. If there is no on_receive, it waits for the #pop call.
0
     def on_recieve(&block)
0
- @on_receive = block || @on_receive
0
+ self.on_receive = block if block
0
+ @on_receive
0
+ end
0
+
0
+ def on_receive=(proc)
0
+ @on_receive = proc
0
+ # define notify! method to invoke a callback
0
+ class << self
0
+ def notify!
0
+ while item = pop
0
+ @on_receive.call(item)
0
+ end
0
+ end
0
+ end
0
+ proc
0
     end
0
     
0
     # Get an object out of the queue.
0
@@ -26,5 +40,12 @@ module StrokeDB
0
       raise "Abstract queue doesn't have a size"
0
     end
0
     alias :length :size
0
+
0
+ protected
0
+
0
+ def notify!
0
+ # do nothing while on_receive is not set
0
+ end
0
+
0
   end
0
 end

Comments

    No one has commented yet.