Class: ConcurrentSHM::Channel::SingleBuffered::Empty

Inherits:
ConcurrentSHM::Channel::SingleBuffered show all
Defined in:
lib/concurrent-shm/channel.rb

Overview

A single-buffered channel with zero-width packets.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ConcurrentSHM::Channel

#close

Class Method Details

.new(shm, offset: 0, autosize: true) ⇒ Object

Allocates a single-buffered, zero-width channel.



150
151
152
153
154
155
# File 'lib/concurrent-shm/channel.rb', line 150

def self.new(shm, offset: 0, autosize: true)
  alloc(shm, 2, offset: offset, autosize: autosize) do |body|
    @state = body[0].as_intptr
    @closed = body[1].as_intptr
  end
end

Instance Method Details

#recvnil

Receive a zero-width packet over the channel. Blocks if the buffer is empty.

Returns:

  • (nil)


163
164
165
# File 'lib/concurrent-shm/channel.rb', line 163

def recv
  do_recv
end

#sendnil

Send a zero-width packet over the channel. Blocks if the buffer is full.

Returns:

  • (nil)

Raises:



158
159
160
# File 'lib/concurrent-shm/channel.rb', line 158

def send
  do_send
end