Module: Synctest::Patches::ConditionVariablePatch

Defined in:
lib/synctest/patches.rb

Instance Method Summary collapse

Instance Method Details

#broadcastObject



290
291
292
293
294
295
# File 'lib/synctest/patches.rb', line 290

def broadcast
  bubble = Synctest.bubble_for_operation(self)
  return super unless bubble

  bubble.condition_signal(self, broadcast: true)
end

#initializeObject



268
269
270
271
# File 'lib/synctest/patches.rb', line 268

def initialize(...)
  super
  Synctest.associate(self)
end

#signalObject



283
284
285
286
287
288
# File 'lib/synctest/patches.rb', line 283

def signal
  bubble = Synctest.bubble_for_operation(self)
  return super unless bubble

  bubble.condition_signal(self, broadcast: false)
end

#wait(mutex, timeout = nil) ⇒ Object



273
274
275
276
277
278
279
280
281
# File 'lib/synctest/patches.rb', line 273

def wait(mutex, timeout = nil)
  bubble = Synctest.bubble_for_operation(self)
  return super unless bubble
  unless Synctest.bubble_for(mutex).equal?(bubble)
    raise IsolationError, "a bubbled ConditionVariable requires a Mutex from the same bubble"
  end

  bubble.condition_wait(self, mutex, timeout)
end