Class: Farce::Strict::Port
- Inherits:
-
Internal::Port
- Object
- Internal::Port
- Farce::Strict::Port
- Includes:
- Abstract::Port
- Defined in:
- lib/farce/strict/port.rb
Overview
A Ractor-shareable port that accepts shareable messages directly. Messages retain their identity and envelopes are returned unopened. Only the creating Ractor can receive messages or close the port.
Instance Method Summary collapse
-
#initialize ⇒ BasicObject
constructor
Creates a port without transfer modes.
-
#inspect ⇒ String
A string representation of the port.
-
#send(message) ⇒ self
Sends a message through the port.
Methods included from Abstract::Port
#<<, #close, #closed?, #owned?, #pop, #push, #receive
Methods included from Farce::Shareable
Methods included from Internal::Noncopyable
Constructor Details
#initialize ⇒ BasicObject
Creates a port without transfer modes.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/farce/strict/port.rb', line 20 class Port < Internal::Port include Abstract::Port # @!visibility private # (see #initialize) # CRuby 3.4's backend also accepts an existing port or Ractor. # Keep construction argument-free on every runtime. def self.new = super # rubocop:disable Lint/UselessMethodDefinition # (see Abstract::Port#send) # @raise [Farce::Ractor::IsolationError] if the message is not Ractor-shareable def send() raise Ractor::IsolationError, "value must be Ractor-shareable" unless Ractor.shareable?() super end # @return [String] a string representation of the port def inspect = super.sub(/\A#<.+? (?=(?:to|id):#?\d+)/, "#<Farce::Strict::Port ") end |
Instance Method Details
#inspect ⇒ String
Returns a string representation of the port.
37 |
# File 'lib/farce/strict/port.rb', line 37 def inspect = super.sub(/\A#<.+? (?=(?:to|id):#?\d+)/, "#<Farce::Strict::Port ") |
#send(message) ⇒ self
Sends a message through the port.
31 32 33 34 |
# File 'lib/farce/strict/port.rb', line 31 def send() raise Ractor::IsolationError, "value must be Ractor-shareable" unless Ractor.shareable?() super end |