lib/polyphony/extensions/thread.rb in polyphony-0.99 vs lib/polyphony/extensions/thread.rb in polyphony-0.99.1

- old
+ new

@@ -5,13 +5,17 @@ # Thread extensions class ::Thread attr_reader :main_fiber, :result attr_accessor :backend + # @!visibility private alias_method :orig_initialize, :initialize # Initializes the thread. + # @param args [Array] arguments to pass to thread block + # @yield [any] thread block + # @return [void] def initialize(*args, &block) @join_wait_queue = [] @finalization_mutex = Mutex.new @args = args @block = block @@ -25,10 +29,11 @@ @main_fiber = Fiber.current @main_fiber.setup_main_fiber setup_fiber_scheduling end + # @!visibility private alias_method :orig_join, :join # call-seq: # thread.join -> result # thread.join(timeout) -> result @@ -54,10 +59,11 @@ end timeout ? move_on_after(timeout) { watcher.await } : watcher.await end alias_method :await, :join + # @!visibility private alias_method :orig_raise, :raise # call-seq: # thread.raise # thread.raise(exception_class) @@ -75,10 +81,11 @@ sleep 0.0001 until @ready main_fiber&.raise(error) end + # @!visibility private alias_method :orig_kill, :kill # Terminates the thread. # # @return [Thread] self @@ -87,10 +94,11 @@ raise Polyphony::Terminate self end + # @!visibility private alias_method :orig_inspect, :inspect # Returns a string representation of the thread for debugging purposes. # # @return [String] string representation @@ -126,10 +134,10 @@ backend.idle_gc_period = period end # Sets the idle handler for the thread's backend. # - # @param &block [Proc] idle handler + # @yield [] idle handler # @return [Proc] idle handler def on_idle(&block) backend.idle_proc = block end