Class: Nursery::Child

Inherits:
Object
  • Object
show all
Defined in:
lib/nursery/child.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nursery, config, job) ⇒ Child

Returns a new instance of Child.



8
9
10
11
12
13
# File 'lib/nursery/child.rb', line 8

def initialize(nursery, config, job)
	@nursery = nursery
	@thread = Thread.new(&job)
	@thread[:nursery] = nursery
	@config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/nursery/child.rb', line 6

def config
  @config
end

#nurseryObject (readonly)

Returns the value of attribute nursery.



4
5
6
# File 'lib/nursery/child.rb', line 4

def nursery
  @nursery
end

#threadObject (readonly)

Returns the value of attribute thread.



5
6
7
# File 'lib/nursery/child.rb', line 5

def thread
  @thread
end

Instance Method Details

#finishObject



15
16
17
18
19
20
21
22
# File 'lib/nursery/child.rb', line 15

def finish
	thread.join unless self.thread == Thread.current
	nil
rescue CancelledJob
	nil
rescue Exception
	raise unless @config[:swallow_exceptions]
end