Async::SafeSourceAsyncSafeTransferableThreadQueue

module TransferableThreadQueue

Automatically transfers ownership of objects when they are removed from a Thread::Queue.

When included in Thread::Queue or Thread::SizedQueue, this module wraps pop/deq/shift methods to automatically transfer ownership of the dequeued object to the fiber that dequeues it.

Definitions

def pop(...)

Pop an object from the queue and transfer ownership to the current fiber.

Signature

parameter arguments Array

Arguments passed to the original pop method.

returns Object

The dequeued object with transferred ownership.

Implementation

def pop(...)
	object = super(...)
	Async::Safe.transfer(object)
	object
end

def deq(...)

Dequeue an object from the queue and transfer ownership to the current fiber.

Alias for #pop.

Signature

parameter arguments Array

Arguments passed to the original deq method.

returns Object

The dequeued object with transferred ownership.

Implementation

def deq(...)
	object = super(...)
	Async::Safe.transfer(object)
	object
end

def shift(...)

Shift an object from the queue and transfer ownership to the current fiber.

Alias for #pop.

Signature

parameter arguments Array

Arguments passed to the original shift method.

returns Object

The dequeued object with transferred ownership.

Implementation

def shift(...)
	object = super(...)
	Async::Safe.transfer(object)
	object
end