Method: Concurrent::IVar#set
- Defined in:
- lib/concurrent/ivar.rb
#set(value = NULL) { ... } ⇒ IVar
Set the ‘IVar` to a value and wake or notify all threads waiting on it.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/concurrent/ivar.rb', line 112 def set(value = NULL) check_for_block_or_value!(block_given?, value) raise MultipleAssignmentError unless compare_and_set_state(:processing, :pending) begin value = yield if block_given? complete_without_notification(true, value, nil) rescue => ex complete_without_notification(false, nil, ex) end notify_observers(self.value, reason) self end |