Sha256: 729e8819d402e24c88e6276a09437c774d8ff0bd47754c32ed54dc72bd99771e
Contents?: true
Size: 893 Bytes
Versions: 12
Compression:
Stored size: 893 Bytes
Contents
class Thread def self.uid "#{$$}.#{Thread.current.object_id}" end def self.deferred(&block) new { Thread.current.abort_on_exception = true begin yield rescue App.logger.warn "Caught exception in background processing: #{$!}" end } end end module Thread::Etest def test_deferred i = 0 Thread.deferred do i = 1 end Thread.sleep 0.05 assert_equal(1, i) end def test_deferred_exception i = 0 Thread.deferred do i = 1 raise i = 2 end Thread.sleep 0.05 assert_equal(1, i) end def test_pids pids = [ Thread.uid ] Thread.deferred { pids[1] = Thread.uid } Thread.deferred { pids[2] = Thread.uid } Thread.sleep 0.05 assert_equal(pids, pids.compact) assert_equal(pids, pids.uniq) end end if VEX_TEST == "base"
Version data entries
12 entries across 12 versions & 1 rubygems