class Async::Container::Thread::Instance
Represents a running child thread from the point of view of the child thread.
Public Class Methods
for(thread)
click to toggle source
Wrap an instance around the {Thread} instance from within the threaded child. @parameter thread [Thread] The thread intance to wrap.
# File lib/async/container/thread.rb, line 56 def self.for(thread) instance = self.new(thread.out) return instance end
new(io)
click to toggle source
Calls superclass method
Async::Container::Notify::Pipe::new
# File lib/async/container/thread.rb, line 62 def initialize(io) @name = nil @thread = ::Thread.current super end
Public Instance Methods
exec(*arguments, ready: true, **options)
click to toggle source
Execute a child process using {::Process.spawn}. In order to simulate {::Process.exec}, an {Exit} instance is raised to propagage exit status. This creates the illusion that this method does not return (normally).
# File lib/async/container/thread.rb, line 83 def exec(*arguments, ready: true, **options) if ready self.ready!(status: "(spawn)") if ready else self.before_spawn(arguments, options) end begin # TODO prefer **options... but it doesn't support redirections on < 2.7 pid = ::Process.spawn(*arguments, options) ensure _, status = ::Process.wait2(pid) raise Exit, status end end
name()
click to toggle source
Get the name of the thread. @returns [String]
# File lib/async/container/thread.rb, line 77 def name @thread.name end
name=(value)
click to toggle source
Set the name of the thread. @parameter value [String] The name to set.
# File lib/async/container/thread.rb, line 71 def name= value @thread.name = value end