Async::ContainerSourceAsyncContainerThreadedChildInstance

class Instance

Represents a running child thread from the point of view of the child thread.

Definitions

def self.for(thread)

Wrap an instance around the Thread instance from within the threaded child.

Signature

parameter thread Thread

The thread intance to wrap.

Implementation

def self.for(thread)
	instance = self.new(thread.out)
	
	return instance
end

def name= value

Set the name of the thread.

Signature

parameter value String

The name to set.

Implementation

def name= value
	@thread.name = value
end

def name

Get the name of the thread.

Signature

returns String

Implementation

def name
	@thread.name
end

def exec(*arguments, ready: true, **options)

Execute a child process using ::Process.spawn. In order to simulate ::Process.exec, an class Async::Container::Threaded::Child::Exit instance is raised to propagage exit status. This creates the illusion that this method does not return (normally).

Implementation

def exec(*arguments, ready: true, **options)
	if ready
		self.ready!(status: "(spawn)")
	else
		self.before_spawn(arguments, options)
	end
	
	begin
		pid = ::Process.spawn(*arguments, **options)
	ensure
		_, status = ::Process.wait2(pid)
		
		raise Exit, status
	end
end