Class: ConcurrentSHM::Channel::Buffered::Empty
- Inherits:
-
ConcurrentSHM::Channel::Buffered
- Object
- ConcurrentSHM::Channel
- ConcurrentSHM::Channel::Buffered
- ConcurrentSHM::Channel::Buffered::Empty
- Defined in:
- lib/concurrent-shm/channel.rb
Overview
A buffered channel with zero-width packets.
Class Method Summary collapse
-
.new(shm, depth:, offset: 0, autosize: true) ⇒ Object
Allocates a buffered, zero-width channel.
Instance Method Summary collapse
-
#recv ⇒ nil
Receive a zero-width packet over the channel.
-
#send ⇒ nil
Send a zero-width packet over the channel.
Methods inherited from ConcurrentSHM::Channel
Class Method Details
.new(shm, depth:, offset: 0, autosize: true) ⇒ Object
Allocates a buffered, zero-width channel.
270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/concurrent-shm/channel.rb', line 270 def self.new(shm, depth:, offset: 0, autosize: true) raise RangeError, "Depth must be > 0" unless depth > 0 dbytes = bytes_for(depth) { raise RangeError, "Depth must be less than 2^32" } alloc(shm, dbytes*2 + 1, offset: offset, autosize: autosize) do |body| @depth = depth @read = body[0, dbytes].as_uintptr @written = body[dbytes, dbytes].as_uintptr @closed = body[dbytes*2].as_intptr end end |
Instance Method Details
#recv ⇒ nil
Receive a zero-width packet over the channel. Blocks if the buffer is empty.
291 292 293 |
# File 'lib/concurrent-shm/channel.rb', line 291 def recv do_recv end |
#send ⇒ nil
Send a zero-width packet over the channel. Blocks if the buffer is full.
285 286 287 |
# File 'lib/concurrent-shm/channel.rb', line 285 def send do_send end |