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-5.2.1 lib/rainbows/worker_yield.rb
rainbows-5.2.0 lib/rainbows/worker_yield.rb
rainbows-5.1.1 lib/rainbows/worker_yield.rb
rainbows-5.1.0 lib/rainbows/worker_yield.rb
rainbows-5.0.0.5.ge717 lib/rainbows/worker_yield.rb
rainbows-5.0.0 lib/rainbows/worker_yield.rb
rainbows-4.7.0 lib/rainbows/worker_yield.rb
rainbows-4.6.2 lib/rainbows/worker_yield.rb
rainbows-4.6.1 lib/rainbows/worker_yield.rb
rainbows-4.6.0.4.g4108 lib/rainbows/worker_yield.rb
rainbows-4.6.0 lib/rainbows/worker_yield.rb
rainbows-4.5.0 lib/rainbows/worker_yield.rb
rainbows-4.4.3 lib/rainbows/worker_yield.rb
rainbows-4.4.2 lib/rainbows/worker_yield.rb
rainbows-4.4.1.1.gd5c8c lib/rainbows/worker_yield.rb
rainbows-4.4.1 lib/rainbows/worker_yield.rb
rainbows-4.4.0 lib/rainbows/worker_yield.rb
rainbows-4.3.1 lib/rainbows/worker_yield.rb
rainbows-4.3.0 lib/rainbows/worker_yield.rb
rainbows-4.2.0 lib/rainbows/worker_yield.rb