Class: Obuf::ProtectedLens
Overview
Similar to Obuf::Lens but protects all the operations that change the IO offset with a Mutex.
Constant Summary
Constants inherited from Lens
Lens::DELIM, Lens::END_RECORD, Lens::NothingToRecover
Instance Method Summary collapse
-
#<<(object_to_store) ⇒ Object
Store an object.
-
#initialize(io) ⇒ ProtectedLens
constructor
A new instance of ProtectedLens.
- #recover_at(idx) ⇒ Object
- #recover_object ⇒ Object
Methods inherited from Lens
Constructor Details
#initialize(io) ⇒ ProtectedLens
Returns a new instance of ProtectedLens.
6 7 8 9 |
# File 'lib/obuf/protected_lens.rb', line 6 def initialize(io) super @mutex = Mutex.new end |
Instance Method Details
#<<(object_to_store) ⇒ Object
Store an object
12 13 14 |
# File 'lib/obuf/protected_lens.rb', line 12 def <<(object_to_store) @mutex.synchronize { super } end |
#recover_at(idx) ⇒ Object
16 17 18 |
# File 'lib/obuf/protected_lens.rb', line 16 def recover_at(idx) @mutex.synchronize { super } end |
#recover_object ⇒ Object
20 21 22 |
# File 'lib/obuf/protected_lens.rb', line 20 def recover_object @mutex.synchronize { super } end |