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.
Constructor Details
#initialize(path) ⇒ Context
Initialize the context with the given path.
83 84 85 86 87 88 |
# File 'lib/async/container/notify/server.rb', line 83 def initialize(path) @path = path @bound = Addrinfo.unix(@path, ::Socket::SOCK_DGRAM).bind @state = {} end |
Instance Method Details
#close ⇒ Object
Close the bound context.
91 92 93 94 95 |
# File 'lib/async/container/notify/server.rb', line 91 def close @bound.close File.unlink(@path) end |
#receive ⇒ Object
Receive a message from the bound context.
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/async/container/notify/server.rb', line 100 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 |