Class: Async::Container::Notify::Server::Context
- Inherits:
-
Object
- Object
- Async::Container::Notify::Server::Context
- Defined in:
- lib/async/container/notify/server.rb
Overview
A bound context for receiving messages.
Instance Method Summary collapse
-
#close ⇒ Object
Close the bound context.
-
#initialize(path) ⇒ Context
constructor
Initialize the context with the given path.
-
#receive ⇒ Object
Receive a message from the bound context.
-
#wait_until_ready ⇒ Object
Wait until a “ready” message is received from the child process.
Constructor Details
#initialize(path) ⇒ Context
Initialize the context with the given path.
102 103 104 105 106 107 |
# File 'lib/async/container/notify/server.rb', line 102 def initialize(path) @path = path @bound = Addrinfo.unix(@path, ::Socket::SOCK_DGRAM).bind @state = {} end |
Instance Method Details
#close ⇒ Object
Close the bound context.
110 111 112 113 114 |
# File 'lib/async/container/notify/server.rb', line 110 def close @bound.close File.unlink(@path) end |
#receive ⇒ Object
Receive a message from the bound context.
119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/async/container/notify/server.rb', line 119 def receive while true data, _address, _flags, *_controls = @bound.recvmsg(MAXIMUM_MESSAGE_SIZE) = Server.load(data) if block_given? yield else return end end end |
#wait_until_ready ⇒ Object
Wait until a “ready” message is received from the child process.
134 135 136 137 138 139 140 |
# File 'lib/async/container/notify/server.rb', line 134 def wait_until_ready while = receive if [:ready] == true return end end end |