Module: Pitchfork::SharedMemory
Defined Under Namespace
Classes: Field
Constant Summary collapse
- PER_DROP =
Raindrops::PAGE_SIZE / Raindrops::SIZE
- CURRENT_GENERATION_OFFSET =
0
- SHUTDOWN_OFFSET =
1
- MOLD_TICK_OFFSET =
2
- MOLD_PROMOTION_TICK_OFFSET =
3
- WORKER_TICK_OFFSET =
4
- DROPS =
[Raindrops.new(PER_DROP)]
Instance Method Summary collapse
- #[](offset) ⇒ Object
- #current_generation ⇒ Object
- #current_generation=(value) ⇒ Object
- #mold_deadline ⇒ Object
- #mold_promotion_deadline ⇒ Object
-
#preallocate_drops(workers_count) ⇒ Object
Since workers are created from another process, we have to pre-allocate the drops so they are shared between everyone.
- #shutting_down! ⇒ Object
- #shutting_down? ⇒ Boolean
- #worker_deadline(worker_nr) ⇒ Object
Instance Method Details
#[](offset) ⇒ Object
61 62 63 |
# File 'lib/pitchfork/shared_memory.rb', line 61 def [](offset) Field.new(offset) end |
#current_generation ⇒ Object
18 19 20 |
# File 'lib/pitchfork/shared_memory.rb', line 18 def current_generation DROPS[0][CURRENT_GENERATION_OFFSET] end |
#current_generation=(value) ⇒ Object
22 23 24 |
# File 'lib/pitchfork/shared_memory.rb', line 22 def current_generation=(value) DROPS[0][CURRENT_GENERATION_OFFSET] = value end |
#mold_deadline ⇒ Object
49 50 51 |
# File 'lib/pitchfork/shared_memory.rb', line 49 def mold_deadline self[MOLD_TICK_OFFSET] end |
#mold_promotion_deadline ⇒ Object
53 54 55 |
# File 'lib/pitchfork/shared_memory.rb', line 53 def mold_promotion_deadline self[MOLD_PROMOTION_TICK_OFFSET] end |
#preallocate_drops(workers_count) ⇒ Object
Since workers are created from another process, we have to pre-allocate the drops so they are shared between everyone.
However this doesn’t account for TTIN signals that increase the number of workers, but we should probably remove that feature too.
70 71 72 73 74 |
# File 'lib/pitchfork/shared_memory.rb', line 70 def preallocate_drops(workers_count) 0.upto(((WORKER_TICK_OFFSET + workers_count) / PER_DROP.to_f).ceil) do |i| DROPS[i] ||= Raindrops.new(PER_DROP) end end |
#shutting_down! ⇒ Object
26 27 28 |
# File 'lib/pitchfork/shared_memory.rb', line 26 def shutting_down! DROPS[0][SHUTDOWN_OFFSET] = 1 end |
#shutting_down? ⇒ Boolean
30 31 32 |
# File 'lib/pitchfork/shared_memory.rb', line 30 def shutting_down? DROPS[0][SHUTDOWN_OFFSET] > 0 end |
#worker_deadline(worker_nr) ⇒ Object
57 58 59 |
# File 'lib/pitchfork/shared_memory.rb', line 57 def worker_deadline(worker_nr) self[WORKER_TICK_OFFSET + worker_nr] end |