Sha256: 50b4f5646c2412294caaec5ee56d9e177defca0da2a15e3adbe41543faa331ed

Contents?: true

Size: 639 Bytes

Versions: 28

Compression:

Stored size: 639 Bytes

Contents

# -*- encoding: binary -*-
# :enddoc:
module Rainbows::WorkerYield

  # Sleep if we're busy (and let other threads run).  Another less busy
  # worker process may take it for us if we sleep. This is gross but
  # other options still suck because they require expensive/complicated
  # synchronization primitives for _every_ case, not just this unlikely
  # one.  Since this case is (or should be) uncommon, just busy wait
  # when we have to.  We don't use Thread.pass because it needlessly
  # spins the CPU during I/O wait, CPU cycles that can be better used by
  # other worker _processes_.
  def worker_yield
    sleep(0.01)
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
rainbows-4.1.0 lib/rainbows/worker_yield.rb
rainbows-4.0.0 lib/rainbows/worker_yield.rb
rainbows-3.4.0 lib/rainbows/worker_yield.rb
rainbows-3.3.0 lib/rainbows/worker_yield.rb
rainbows-3.2.0 lib/rainbows/worker_yield.rb
rainbows-3.1.0 lib/rainbows/worker_yield.rb
rainbows-3.0.0 lib/rainbows/worker_yield.rb
rainbows-2.1.0 lib/rainbows/worker_yield.rb