Class: ParallelSpecs::Pids

Inherits:
Object
  • Object
show all
Defined in:
lib/parallel_specs/pids.rb

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Pids

Returns a new instance of Pids.



7
8
9
10
# File 'lib/parallel_specs/pids.rb', line 7

def initialize(file_path)
  @file_path = file_path
  @mutex = Mutex.new
end

Instance Method Details

#add(pid) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/parallel_specs/pids.rb', line 12

def add(pid)
  mutex.synchronize do
    read
    pids << pid.to_i
    save
  end
end

#allObject



28
29
30
31
32
33
# File 'lib/parallel_specs/pids.rb', line 28

def all
  mutex.synchronize do
    read
    pids.dup
  end
end

#delete(pid) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/parallel_specs/pids.rb', line 20

def delete(pid)
  mutex.synchronize do
    read
    pids.delete(pid.to_i)
    save
  end
end