lib/async/container.rb in async-container-0.14.1 vs lib/async/container.rb in async-container-0.15.0
- old
+ new
@@ -16,34 +16,12 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-require_relative 'container/forked'
-require_relative 'container/threaded'
-require_relative 'container/hybrid'
+require_relative 'container/controller'
-require 'etc'
-
module Async
# Containers execute one or more "instances" which typically contain a reactor. A container spawns "instances" using threads and/or processes. Because these are resources that must be cleaned up some how (either by `join` or `waitpid`), their creation is deferred until the user invokes `Container#wait`. When executed this way, the container guarantees that all "instances" will be complete once `Container#wait` returns. Containers are constructs for achieving parallelism, and are not designed to be used directly for concurrency. Typically, you'd create one or more container, add some tasks to it, and then wait for it to complete.
module Container
- def self.best_container_class
- if Process.respond_to?(:fork) and Process.respond_to?(:setpgid)
- return Forked
- else
- return Threaded
- end
- end
-
- # @return [Integer] the number of hardware processors which can run threads/processes simultaneously.
- def self.processor_count
- Etc.nprocessors
- rescue
- 2
- end
-
- def self.new(*arguments)
- best_container_class.new(*arguments)
- end
end
end