module Async::Container

def self.processor_count(env = ENV)

@raises [RuntimeError] If the process count is invalid.
@returns [Integer] The number of hardware processors which can run threads/processes simultaneously.
The processor count which may be used for the default number of container threads/processes. You can override the value provided by the system by specifying the `ASYNC_CONTAINER_PROCESSOR_COUNT` environment variable.
def self.processor_count(env = ENV)
	count = env.fetch(ASYNC_CONTAINER_PROCESSOR_COUNT) do
		Etc.nprocessors rescue 1
	end.to_i
	
	if count < 1
		raise RuntimeError, "Invalid processor count #{count}!"
	end
	
	return count
end