[前][次][番号順一覧][スレッド一覧]

ruby-changes:57833

From: Hiroshi <ko1@a...>
Date: Fri, 20 Sep 2019 15:31:13 +0900 (JST)
Subject: [ruby-changes:57833] 9d25c652a9 (master): Removed ThreadsWait from the ruby repository

https://git.ruby-lang.org/ruby.git/commit/?id=9d25c652a9

From 9d25c652a98f0a5bc552f81846c6dc975dc2f307 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Fri, 20 Sep 2019 14:21:04 +0900
Subject: Removed ThreadsWait from the ruby repository


diff --git a/NEWS b/NEWS
index 9ac9d0d..a4d7817 100644
--- a/NEWS
+++ b/NEWS
@@ -332,6 +332,7 @@ RubyGems:: https://github.com/ruby/ruby/blob/trunk/NEWS#L332
   * Scanf
   * Shell
   * Synchronizer
+  * ThreadsWait
 
 === Stdlib compatibility issues (excluding feature bug fixes)
 
diff --git a/doc/standard_library.rdoc b/doc/standard_library.rdoc
index 74567d0..975bc39 100644
--- a/doc/standard_library.rdoc
+++ b/doc/standard_library.rdoc
@@ -87,7 +87,6 @@ Racc:: A LALR(1) parser generator written in Ruby. https://github.com/ruby/ruby/blob/trunk/doc/standard_library.rdoc#L87
 RDoc:: Produces HTML and command-line documentation for Ruby
 REXML:: An XML toolkit for Ruby
 RSS:: Family of libraries that support various formats of XML "feeds"
-ThreadsWait:: Watches for termination of multiple threads
 Tracer:: Outputs a source level execution trace of a Ruby program
 WEBrick:: An HTTP server toolkit for Ruby
 
diff --git a/lib/thwait.rb b/lib/thwait.rb
deleted file mode 100644
index 541fe1e..0000000
--- a/lib/thwait.rb
+++ /dev/null
@@ -1,140 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/doc/standard_library.rdoc#L0
-# frozen_string_literal: false
-#
-#   thwait.rb - thread synchronization class
-#       $Release Version: 0.9 $
-#       $Revision: 1.3 $
-#       by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd.)
-
-require "e2mmap"
-
-#
-# This class watches for termination of multiple threads.  Basic functionality
-# (wait until specified threads have terminated) can be accessed through the
-# class method ThreadsWait::all_waits.  Finer control can be gained using
-# instance methods.
-#
-# Example:
-#
-#   ThreadsWait.all_waits(thr1, thr2, ...) do |t|
-#     STDERR.puts "Thread #{t} has terminated."
-#   end
-#
-#
-#   th = ThreadsWait.new(thread1,...)
-#   th.next_wait # next one to be done
-#
-#
-class ThreadsWait
-  extend Exception2MessageMapper
-  def_exception("ErrNoWaitingThread", "No threads for waiting.")
-  def_exception("ErrNoFinishedThread", "No finished threads.")
-
-  #
-  # Waits until all specified threads have terminated.  If a block is provided,
-  # it is executed for each thread as they terminate.
-  #
-  def ThreadsWait.all_waits(*threads) # :yield: thread
-    tw = ThreadsWait.new(*threads)
-    if block_given?
-      tw.all_waits do |th|
-        yield th
-      end
-    else
-      tw.all_waits
-    end
-  end
-
-  #
-  # Creates a ThreadsWait object, specifying the threads to wait on.
-  # Non-blocking.
-  #
-  def initialize(*threads)
-    @threads = []
-    @wait_queue = Thread::Queue.new
-    join_nowait(*threads) unless threads.empty?
-  end
-
-  # Returns the array of threads that have not terminated yet.
-  attr_reader :threads
-
-  #
-  # Returns +true+ if there are no threads in the pool still running.
-  #
-  def empty?
-    @threads.empty?
-  end
-
-  #
-  # Returns +true+ if any thread has terminated and is ready to be collected.
-  #
-  def finished?
-    !@wait_queue.empty?
-  end
-
-  #
-  # Waits for specified threads to terminate, and returns when one of
-  # the threads terminated.
-  #
-  def join(*threads)
-    join_nowait(*threads)
-    next_wait
-  end
-
-  #
-  # Specifies the threads that this object will wait for, but does not actually
-  # wait.
-  #
-  def join_nowait(*threads)
-    threads.flatten!
-    @threads.concat threads
-    for th in threads
-      Thread.start(th) do |t|
-        begin
-          t.join
-        ensure
-          @wait_queue.push t
-        end
-      end
-    end
-  end
-
-  #
-  # Waits until any of the specified threads has terminated, and returns the one
-  # that does.
-  #
-  # If there is no thread to wait, raises +ErrNoWaitingThread+.  If +nonblock+
-  # is true, and there is no terminated thread, raises +ErrNoFinishedThread+.
-  #
-  def next_wait(nonblock = nil)
-    ThreadsWait.fail ErrNoWaitingThread if @threads.empty?
-    begin
-      @threads.delete(th = @wait_queue.pop(nonblock))
-      th
-    rescue ThreadError
-      ThreadsWait.fail ErrNoFinishedThread
-    end
-  end
-
-  #
-  # Waits until all of the specified threads are terminated.  If a block is
-  # supplied for the method, it is executed for each thread termination.
-  #
-  # Raises exceptions in the same manner as +next_wait+.
-  #
-  def all_waits
-    until @threads.empty?
-      th = next_wait
-      yield th if block_given?
-    end
-  end
-end
-
-##
-# An alias for ThreadsWait from thwait.rb
-
-ThWait = ThreadsWait
-
-# Documentation comments:
-#  - Source of documentation is evenly split between Nutshell, existing
-#    comments, and my own rephrasing.
-#  - I'm not particularly confident that the comments are all exactly correct.
diff --git a/lib/thwait/thwait.gemspec b/lib/thwait/thwait.gemspec
deleted file mode 100644
index fc03942..0000000
--- a/lib/thwait/thwait.gemspec
+++ /dev/null
@@ -1,26 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/doc/standard_library.rdoc#L0
-begin
-  require_relative "lib/thwait/version"
-rescue LoadError
-  # for Ruby core repository
-  require_relative "version"
-end
-
-Gem::Specification.new do |spec|
-  spec.name          = "thwait"
-  spec.version       = ThreadsWait::VERSION
-  spec.authors       = ["Keiju ISHITSUKA"]
-  spec.email         = ["keiju@r..."]
-
-  spec.summary       = %q{Watches for termination of multiple threads.}
-  spec.description   = %q{Watches for termination of multiple threads.}
-  spec.homepage      = "https://github.com/ruby/thwait"
-  spec.license       = "BSD-2-Clause"
-
-  spec.files         = [".gitignore", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/thwait.rb", "lib/thwait/version.rb", "thwait.gemspec"]
-  spec.bindir        = "exe"
-  spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
-  spec.require_paths = ["lib"]
-
-  spec.add_development_dependency "bundler", "~> 1.16"
-  spec.add_development_dependency "rake", "~> 10.0"
-end
diff --git a/lib/thwait/version.rb b/lib/thwait/version.rb
deleted file mode 100644
index a3ffb3a..0000000
--- a/lib/thwait/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/doc/standard_library.rdoc#L0
-class ThreadsWait
-  VERSION = "0.1.0"
-end
diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb
index 93a19d5..61571e9 100644
--- a/tool/sync_default_gems.rb
+++ b/tool/sync_default_gems.rb
@@ -31,7 +31,6 @@ https://github.com/ruby/ruby/blob/trunk/tool/sync_default_gems.rb#L31
 # * https://github.com/ruby/sync
 # * https://github.com/ruby/tracer
 # * https://github.com/ruby/forwardable
-# * https://github.com/ruby/thwait
 # * https://github.com/ruby/e2mmap
 # * https://github.com/ruby/mutex_m
 # * https://github.com/ruby/racc
@@ -72,7 +71,6 @@ $repositories = { https://github.com/ruby/ruby/blob/trunk/tool/sync_default_gems.rb#L71
   sync: 'ruby/sync',
   tracer: 'ruby/tracer',
   forwardable: "ruby/forwardable",
-  thwait: "ruby/thwait",
   e2mmap: "ruby/e2mmap",
   mutex_m: "ruby/mutex_m",
   racc: "ruby/racc"
@@ -194,10 +192,6 @@ def sync_default_gems(gem) https://github.com/ruby/ruby/blob/trunk/tool/sync_default_gems.rb#L192
     cp_r("#{upstream}/ext/fcntl", "ext")
     cp_r("#{upstream}/fcntl.gemspec", "ext/fcntl")
     `git checkout ext/fcntl/depend`
-  when "thwait"
-    rm_rf(%w[lib/thwait*])
-    cp_r(Dir.glob("#{upstream}/lib/*"), "lib")
-    cp_r("#{upstream}/thwait.gemspec", "lib/thwait")
   when "e2mmap"
     rm_rf(%w[lib/e2mmap*])
     cp_r(Dir.glob("#{upstream}/lib/*"), "lib")
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]