Sha256: 7874926930ed05c72c4dc65c4c6512b4f997c2230154c15f32c875a0ecdcf101
Contents?: true
Size: 927 Bytes
Versions: 4
Compression:
Stored size: 927 Bytes
Contents
require 'thread' require 'concurrent/global_thread_pool' module Kernel # Post the given agruments and block to the Global Thread Pool. # # @param args [Array] zero or more arguments for the block # @param block [Proc] operation to be performed concurrently # # @return [true,false] success/failre of thread creation # # @note Althought based on Go's goroutines and Erlang's spawn/1, # Ruby has a vastly different runtime. Threads aren't nearly as # efficient in Ruby. Use this function appropriately. # # @see http://golang.org/doc/effective_go.html#goroutines # @see https://gobyexample.com/goroutines def go(*args, &block) return false unless block_given? if args.first.behaves_as?(:global_thread_pool) args.first.post(*args.slice(1, args.length), &block) else $GLOBAL_THREAD_POOL.post(*args, &block) end end module_function :go end
Version data entries
4 entries across 4 versions & 1 rubygems