Class: Aggro::ZeroMQTransport::Server
- Inherits:
-
Object
- Object
- Aggro::ZeroMQTransport::Server
- Defined in:
- lib/aggro/zeromq_transport/server.rb
Overview
Public: Server to handle messages from nanomsg clients.
Defined Under Namespace
Classes: ServerAlreadyRunning, Workload
Constant Summary collapse
- DEFAULT_WORKER_COUNT =
16
Instance Method Summary collapse
-
#initialize(endpoint, callable = nil, &block) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(endpoint, callable = nil, &block) ⇒ Server
Returns a new instance of Server.
20 21 22 23 24 25 26 27 28 |
# File 'lib/aggro/zeromq_transport/server.rb', line 20 def initialize(endpoint, callable = nil, &block) fail ArgumentError unless callable || block_given? @callable = block_given? ? block : callable @endpoint = endpoint @inproc_endpoint = "inproc://aggro-server-#{SecureRandom.hex}" @reply_mutex = Mutex.new @work_queue = Queue.new end |
Instance Method Details
#start ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/aggro/zeromq_transport/server.rb', line 30 def start fail ServerAlreadyRunning if @running @running = true start_master DEFAULT_WORKER_COUNT.times { start_worker } self end |
#stop ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/aggro/zeromq_transport/server.rb', line 40 def stop return self unless @running @running = false self end |