Class: Mongo::TimeoutThread
Instance Attribute Summary collapse
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #cancel ⇒ Object
-
#initialize(collection, doc, timeout) ⇒ TimeoutThread
constructor
A new instance of TimeoutThread.
- #stop ⇒ Object
- #trigger ⇒ Object
Constructor Details
#initialize(collection, doc, timeout) ⇒ TimeoutThread
Returns a new instance of TimeoutThread.
7 8 9 10 11 12 13 |
# File 'lib/jmongo/mongo/utils.rb', line 7 def initialize(collection, doc, timeout) @collection = collection @doc = doc @timeout = timeout @queue = SizedQueue.new(1) spawn_thread end |
Instance Attribute Details
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
6 7 8 |
# File 'lib/jmongo/mongo/utils.rb', line 6 def thread @thread end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
6 7 8 |
# File 'lib/jmongo/mongo/utils.rb', line 6 def timeout @timeout end |
Instance Method Details
#cancel ⇒ Object
19 20 21 22 |
# File 'lib/jmongo/mongo/utils.rb', line 19 def cancel return if @thread[:cancel] @thread[:cancel] = true end |
#stop ⇒ Object
24 25 26 |
# File 'lib/jmongo/mongo/utils.rb', line 24 def stop @queue.push false end |
#trigger ⇒ Object
15 16 17 |
# File 'lib/jmongo/mongo/utils.rb', line 15 def trigger @queue.push(true) if @queue.length == 0 end |