Class: Thread::Queue
Instance Method Summary collapse
- #clear ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- 
  
    
      #initialize  ⇒ Queue 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Queue. 
- #pop(non_block = false) ⇒ Object (also: #shift, #deq)
- #push(value) ⇒ Object (also: #<<, #enq)
- #size ⇒ Object (also: #length)
Constructor Details
#initialize ⇒ Queue
Returns a new instance of Queue
| 73 74 75 | # File 'opal/stdlib/thread.rb', line 73 def initialize clear end | 
Instance Method Details
#clear ⇒ Object
| 77 78 79 | # File 'opal/stdlib/thread.rb', line 77 def clear @storage = [] end | 
#each(&block) ⇒ Object
| 110 111 112 | # File 'opal/stdlib/thread.rb', line 110 def each(&block) @storage.each(&block) end | 
#pop(non_block = false) ⇒ Object Also known as: shift, deq
| 91 92 93 94 95 96 97 98 | # File 'opal/stdlib/thread.rb', line 91 def pop(non_block = false) if empty? fail ThreadError, "Queue empty" if non_block fail ThreadError, "Deadlock" end @storage.shift end | 
#push(value) ⇒ Object Also known as: <<, enq
| 103 104 105 | # File 'opal/stdlib/thread.rb', line 103 def push(value) @storage.push(value) end | 
#size ⇒ Object Also known as: length
| 85 86 87 | # File 'opal/stdlib/thread.rb', line 85 def size @storage.size end |