Class: ConcurrentSHM::Channel::Unbuffered::Empty

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

Overview

An unbuffered 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 an unbuffered, zero-width channel.



18
19
20
21
22
23
# File 'lib/concurrent-shm/channel.rb', line 18

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 there are no senders.

Returns:

  • (nil)


34
35
36
# File 'lib/concurrent-shm/channel.rb', line 34

def recv
  do_recv
end

#sendnil

Send a zero-width packet over the channel. Blocks if there are no receivers.

Returns:

  • (nil)

Raises:



28
29
30
# File 'lib/concurrent-shm/channel.rb', line 28

def send
  do_send
end