Module: Synctest::Patches::MonitorPatch

Defined in:
lib/synctest/patches.rb

Instance Method Summary collapse

Instance Method Details

#enterObject



304
305
306
307
308
309
310
# File 'lib/synctest/patches.rb', line 304

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

  bubble.monitor_enter(self)
  nil
end

#exitObject



341
342
343
344
345
346
347
# File 'lib/synctest/patches.rb', line 341

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

  bubble.monitor_exit(self)
  nil
end

#initializeObject



299
300
301
302
# File 'lib/synctest/patches.rb', line 299

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

#mon_enterObject



312
313
314
315
316
317
318
# File 'lib/synctest/patches.rb', line 312

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

  bubble.monitor_enter(self)
  nil
end

#mon_exitObject



349
350
351
352
353
354
355
# File 'lib/synctest/patches.rb', line 349

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

  bubble.monitor_exit(self)
  nil
end

#mon_owned?Boolean

Returns:

  • (Boolean)


357
358
359
360
361
362
# File 'lib/synctest/patches.rb', line 357

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

  bubble.monitor_owned?(self)
end

#mon_synchronize(&block) ⇒ Object



378
379
380
381
382
383
# File 'lib/synctest/patches.rb', line 378

def mon_synchronize(&block)
  bubble = Synctest.bubble_for_operation(self)
  return super unless bubble

  synchronize(&block)
end

#mon_try_enterObject



327
328
329
330
331
332
# File 'lib/synctest/patches.rb', line 327

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

  bubble.monitor_try_enter(self)
end

#synchronizeObject



364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/synctest/patches.rb', line 364

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

  entered = false
  begin
    bubble.monitor_enter(self)
    entered = true
    yield
  ensure
    bubble.monitor_exit(self) if entered
  end
end

#try_enterObject



320
321
322
323
324
325
# File 'lib/synctest/patches.rb', line 320

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

  bubble.monitor_try_enter(self)
end

#try_mon_enterObject



334
335
336
337
338
339
# File 'lib/synctest/patches.rb', line 334

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

  bubble.monitor_try_enter(self)
end

#wait_for_cond(condition, timeout) ⇒ Object



385
386
387
388
389
390
# File 'lib/synctest/patches.rb', line 385

def wait_for_cond(condition, timeout)
  bubble = Synctest.bubble_for_operation(self)
  return super unless bubble

  bubble.monitor_wait(self, condition, timeout)
end