Class: AudioStream::Sync

Inherits:
Object
  • Object
show all
Defined in:
lib/audio_stream/sync.rb

Constant Summary collapse

NEXT =
:next
COMPLETED =
:completed

Instance Method Summary collapse

Constructor Details

#initializeSync

Returns a new instance of Sync.



6
7
8
9
# File 'lib/audio_stream/sync.rb', line 6

def initialize
  @resume_queue = SizedQueue.new(1)
  @yield_queue = SizedQueue.new(1)
end

Instance Method Details

#finishObject



19
20
21
# File 'lib/audio_stream/sync.rb', line 19

def finish
  @yield_queue.push COMPLETED
end

#resumeObject



11
12
13
# File 'lib/audio_stream/sync.rb', line 11

def resume
  @resume_queue.push true
end

#resume_waitObject



23
24
25
# File 'lib/audio_stream/sync.rb', line 23

def resume_wait
  @resume_queue.pop
end

#yieldObject



15
16
17
# File 'lib/audio_stream/sync.rb', line 15

def yield
  @yield_queue.push NEXT
end

#yield_waitObject



27
28
29
# File 'lib/audio_stream/sync.rb', line 27

def yield_wait
  @yield_queue.pop
end