Class: RSpec::Multicore::EventWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/multicore/reporter_bridge.rb

Overview

Serializes worker reporter events with a shared monotonic sequence.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel) ⇒ EventWriter

Returns a new instance of EventWriter.



137
138
139
140
141
# File 'lib/rspec/multicore/reporter_bridge.rb', line 137

def initialize(channel)
  @channel = channel
  @sequence = 0
  @lock = Mutex.new
end

Instance Attribute Details

#group_indexObject

Returns the value of attribute group_index.



135
136
137
# File 'lib/rspec/multicore/reporter_bridge.rb', line 135

def group_index
  @group_index
end

Instance Method Details

#emit(event, payload) ⇒ Object



143
144
145
146
147
148
# File 'lib/rspec/multicore/reporter_bridge.rb', line 143

def emit(event, payload)
  @lock.synchronize do
    @sequence += 1
    @channel.write([:event, group_index, @sequence, event, payload])
  end
end