123456789_123456789_123456789_123456789_123456789_

Class: SizedQueue

Relationships & Source Files
Inherits: Object
Defined in: thread_sync.c,
thread_sync.c

Overview

This class represents queues of specified size capacity. The push operation may be blocked if the capacity is full.

See Queue for an example of how a SizedQueue works.

Class Method Summary

  • .new(max) constructor

    Creates a fixed-length queue with a maximum size of #max.

Instance Attribute Summary

  • #max rw

    Returns the maximum size of the queue.

  • #max=(number) rw

    Sets the maximum size of the queue to the given number.

Instance Method Summary

Constructor Details

.new(max)

Creates a fixed-length queue with a maximum size of #max.

Instance Attribute Details

#max (rw)

Returns the maximum size of the queue.

#max=(number) (rw)

Sets the maximum size of the queue to the given number.

Instance Method Details

#push(object, non_block = false) #enq(object, non_block = false) #<<(object)
Also known as: #push, #enq

Pushes object to the queue.

If there is no space left in the queue, waits until space becomes available, unless non_block is true. If non_block is true, the thread isn't suspended, and an exception is raised.

#clear

Removes all objects from the queue.

#close(exception = false)

Similar to Queue#close.

The difference is behavior with waiting enqueuing threads.

If there are waiting enqueuing threads, they are interrupted by raising ClosedQueueError('queue closed').

#pop(non_block = false) #deq(non_block = false) #shift(non_block = false)
Also known as: #pop, #shift

Retrieves data from the queue.

If the queue is empty, the calling thread is suspended until data is pushed onto the queue. If non_block is true, the thread isn't suspended, and an exception is raised.

#push(object, non_block = false) #enq(object, non_block = false) #<<(object)

Alias for #<<.

#num_waiting

Returns the number of threads waiting on the queue.

#pop(non_block = false) #deq(non_block = false) #shift(non_block = false)

Alias for #deq.

#push(object, non_block = false) #enq(object, non_block = false) #<<(object)

Alias for #<<.

#pop(non_block = false) #deq(non_block = false) #shift(non_block = false)

Alias for #deq.