Class: Yoda::Server::ConcurrentWriter
- Inherits:
-
Object
- Object
- Yoda::Server::ConcurrentWriter
- Defined in:
- lib/yoda/server/concurrent_writer.rb
Overview
Wrapper class for writer to make thread safe
Instance Method Summary collapse
-
#initialize(channel) ⇒ ConcurrentWriter
constructor
A new instance of ConcurrentWriter.
- #write(*args) ⇒ Object
Constructor Details
#initialize(channel) ⇒ ConcurrentWriter
Returns a new instance of ConcurrentWriter.
6 7 8 9 |
# File 'lib/yoda/server/concurrent_writer.rb', line 6 def initialize(channel) @channel = channel @mutex = Mutex.new end |
Instance Method Details
#write(*args) ⇒ Object
11 12 13 |
# File 'lib/yoda/server/concurrent_writer.rb', line 11 def write(*args) @mutex.synchronize { @channel.write(*args) } end |