Method: Cod::TcpClient#put
- Defined in:
- lib/cod/tcp_client.rb
#put(obj) ⇒ Object
Sends an object to the other end of the channel, if it is connected. If it is not connected, objects sent will queue up and once the internal storage reaches the high watermark, they will be dropped silently.
Example:
channel.put :object
# Really, any Ruby object that the current serializer can turn into
# a string!
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/cod/tcp_client.rb', line 67 def put(obj) # TODO high watermark check # NOTE: predicate will call #try_connect @work_queue.schedule { send(obj) } @work_queue.exclusive { # If we're connected, shut down the worker thread, do all the work # here. check_connection_state } @work_queue.try_work end |