Sha256: e88c560707c95794900b3a0a0d8f3de09784d2c270ea3cdf04a27cb230ef6857

Contents?: true

Size: 751 Bytes

Versions: 5

Compression:

Stored size: 751 Bytes

Contents

# frozen_string_literal: true

# We define end of life-cycle in terms of "Interrupt" (SIGINT), "Terminate" (SIGTERM) and "Kill" (SIGKILL, does not invoke user code).
class Terminate < Interrupt
end

class Isolate
	def initialize(&block)
		
	end
end


parent = Isolate.new do |parent|
	preload_user_code
	server = bind_socket
	children = 4.times.map do
		Isolate.new do |worker|
			app = load_user_application
			worker.ready!
			server.accept do |peer|
				app.handle_request(peer)
			end
		end
	end
	while status = parent.wait
		# Status is not just exit status of process but also can be `:ready` or something else.
	end
end

# Similar to Process.wait(pid)
status = parent.wait
# Life cycle controls
parent.interrupt!
parent.terminate!
parent.kill!

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
async-container-0.16.5 examples/isolate.rb
async-container-0.16.4 examples/isolate.rb
async-container-0.16.3 examples/isolate.rb
async-container-0.16.2 examples/isolate.rb
async-container-0.16.1 examples/isolate.rb