Method: Thread::Channel#send
- Defined in:
- lib/thread/channel.rb
#send(what) ⇒ Object
Send a message to the channel.
If there’s a guard, the value is passed to it, if the guard returns a falsy value an ArgumentError exception is raised and the message is not sent.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/thread/channel.rb', line 33 def send(what) if @check && !@check.call(what) raise ArgumentError, 'guard mismatch' end @mutex.synchronize { @messages << what cond.broadcast if cond? } self end |