class Async::Container::Channel

Provides a basic multi-thread/multi-process uni-directional communication channel.

def close

Close both ends of the pipe.
def close
	close_read
	close_write
end

def close_read

Close the input end of the pipe.
def close_read
	@in.close
end

def close_write

Close the output end of the pipe.
def close_write
	@out.close
end

def initialize

Initialize the channel using a pipe.
def initialize
	@in, @out = ::IO.pipe
end

def receive

@returns [Hash]
Internally, prefers to receive newline formatted JSON, otherwise returns a hash table with a single key `:line` which contains the line of data that could not be parsed as JSON.
Receive an object from the pipe.
def receive
	if data = @in.gets
		begin
			return JSON.parse(data, symbolize_names: true)
		rescue
			return {line: data}
		end
	end
end