Class: Farce::Ractor::Port

Inherits:
Object
  • Object
show all
Defined in:
lib/farce/_yard/ractor.rb

Overview

Either Ractor::Port or a shim for it. It is recommended to use Farce::Port instead, which will always be a subclass of this class, but has added safety and functionality.

Direct Known Subclasses

Port

Instance Method Summary collapse

Instance Method Details

#close

This method returns an undefined value.

Closes the port. Sending to a closed port is prohibited. Receiving is also prohibited if there are no messages in its message queue. Only the Ractor which created the port is allowed to close it.



15
# File 'lib/farce/_yard/ractor.rb', line 15

def close = super

#closed? ⇒ Boolean

Checks it the port is closed.

Returns:

  • (Boolean) —

    true if the port is closed, false otherwise.

See Also:



20
# File 'lib/farce/_yard/ractor.rb', line 20

def closed? = super

#receive ⇒ BasicObject #receive(timeout: nil) ⇒ BasicObject?

Overloads:

  • #receive ⇒ BasicObject

    Receives a message from the port.

    Returns:

    • (BasicObject) —

      The received message.

  • #receive(timeout: nil) ⇒ BasicObject?
    Note:

    Use Farce::Port instead to guarantee a timeout argument on all Ruby implementations.

    Receives a message from the port. Blocks until a message is available or the timeout is reached.

    Parameters:

    • timeout (Numeric, nil) (defaults to: nil) —

      The timeout in seconds, or nil for no timeout.

    Returns:

    • (BasicObject, nil) —

      The received message, or nil if the timeout has been reached.

    Supported Ruby Versions:

    • CRuby 4.1+, JRuby, TruffleRuby

Returns:

  • (BasicObject)

Raises:



35
# File 'lib/farce/_yard/ractor.rb', line 35

def receive = super

#send(message, move: false) ⇒ self Also known as: <<

Sends a message over the port.

Parameters:

  • message (BasicObject) —

    The message to send.

  • move (Boolean) (defaults to: false) —

    Whether to move the message to the Ractor if it isn't sharable.

Returns:

  • (self)

Raises:



42
# File 'lib/farce/_yard/ractor.rb', line 42

def send(message, move: false) = super