Class: ParallelServer::Prefork::Child
- Inherits:
-
Object
- Object
- ParallelServer::Prefork::Child
- Defined in:
- lib/parallel_server/prefork.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(sockets, opts, to_parent, from_parent) ⇒ Child
constructor
A new instance of Child.
- #max_idle ⇒ Integer
- #max_threads ⇒ Integer
- #max_use ⇒ Integer
- #start(block) ⇒ void
Constructor Details
#initialize(sockets, opts, to_parent, from_parent) ⇒ Child
Returns a new instance of Child.
353 354 355 356 357 358 359 360 361 362 363 |
# File 'lib/parallel_server/prefork.rb', line 353 def initialize(sockets, opts, to_parent, from_parent) @sockets = sockets = opts @to_parent = to_parent @from_parent = from_parent @threads = {} @threads_mutex = Mutex.new @threads_cv = ConditionVariable.new @parent_mutex = Mutex.new @status = :run end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
347 348 349 |
# File 'lib/parallel_server/prefork.rb', line 347 def end |
Instance Method Details
#max_idle ⇒ Integer
371 372 373 |
# File 'lib/parallel_server/prefork.rb', line 371 def max_idle [:max_idle] || DEFAULT_MAX_IDLE end |
#max_threads ⇒ Integer
366 367 368 |
# File 'lib/parallel_server/prefork.rb', line 366 def max_threads [:max_threads] || DEFAULT_MAX_THREADS end |
#max_use ⇒ Integer
376 377 378 |
# File 'lib/parallel_server/prefork.rb', line 376 def max_use [:max_use] || DEFAULT_MAX_USE end |
#start(block) ⇒ void
This method returns an undefined value.
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/parallel_server/prefork.rb', line 382 def start(block) queue = Queue.new accept_thread = Thread.new{ accept_loop(block, queue) } reload_thread = Thread.new{ reload_loop(queue) } # wait that accept_loop or reload_loop end queue.pop accept_thread.exit @sockets.each{|s| s.close rescue nil} @threads_mutex.synchronize do notify_status end wait_all_connections reload_thread.exit end |