aboutsummaryrefslogtreecommitdiffstats
path: root/test/thread
Commit message (Collapse)AuthorAgeFilesLines
* Add frozen_string_literal: false for all filesnaruse2015-12-163-0/+3
| | | | | | When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove this test, since it won't reliably pass.headius2015-12-151-4/+1
| | | | | | | | At the point where q.size == 0, we can't know that num_threads threads have actually finished. On e.g. JRuby, they may have called pop but not yet exited the Thread's body. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bootstraptest/runner.rb: use safe navigation operator.hsbt2015-12-141-1/+1
| | | | | | | | | | [fix GH-1142] Patch by @mlarraz * test/openssl/test_pair.rb: ditto. * test/ruby/test_econv.rb: ditto. * test/ruby/test_settracefunc.rb: ditto. * test/thread/test_queue.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_sync.c: reduce the specification of Queue#close.ko12015-11-211-28/+4
| | | | | | | | | | | | | * Queue#close accepts no arguments. * deq'ing on closed queue returns nil, always. [Feature #10600] * test/thread/test_queue.rb: catch up this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/thread/test_queue.rb: catch up last commit.ko12015-09-011-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_tools.c: add Queue#close(exception=false) andko12015-08-261-0/+290
| | | | | | | | | | | | | | | | | | | | | | | | | | SizedQueue#close(exception=false). [Feature #10600] Trying to deq from a closed empty queue return nil if exception parameter equals to false (default). If exception parameter is truthy, it raises ClosedQueueError (< StopIteration). ClosedQueueError inherits StopIteration so that you can write: loop{ e = q.deq; (using e) } Trying to close a closed queue raises ClosedQueueError. Blocking threads to wait deq for Queue and SizedQueue will be restarted immediately by returning nil (exception=false) or raising a ClosedQueueError (exception=true). Blocking threads to wait enq for SizedQueue will be restarted by raising a ClosedQueueError immediately. The above specification is not proposed specification, so that we need to continue discussion to conclude specification this method. * test/thread/test_queue.rb: add tests originally written by John Anderson and modify detailed behavior. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use Timeout.timeoutnobu2015-07-131-1/+1
| | | | | | | * time: Object#timeout has been deprecated a long time ago, use Timeout.timeout. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/lib/envutil.rb: Moved from test/ruby/.akr2014-11-132-2/+0
| | | | | | | | | | | | | | * test/lib/find_executable.rb: Ditto. * test/lib/memory_status.rb: Ditto. * test/lib/test/unit.rb: require envutil. * test/: Don't require envutil in test files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* normalize reference to Timeout::Errornormal2014-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | | From: John Bachir <j@jjb.cc> * bootstraptest/test_io.rb (assert_finish): normalize rescue for Timeout::Error * lib/net/ftp.rb (Net#read_timeout): ditto for doc * lib/resolv.rb (Resolv::ResolvTimeout): ditto for subclass * lib/webrick/httprequest.rb (_read_data): ditto for rescue * sample/timeout.rb (p timeout): ditto for call * test/drb/drbtest.rb (test_06_timeout): ditto * test/ruby/test_readpartial.rb (test_open_pipe): ditto * test/thread/test_queue.rb (test_queue_thread_raise): ditto * thread.c (rb_thread_s_handle_interrupt): ditto for doc [ruby-core:65481] [misc #10339] TimeoutError is a legacy constant, Timeout::Error is the canonical constant. This patch normalizes all code and comments to reference Timeout::Error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread.c: check initializednobu2014-08-192-0/+18
| | | | | | | * ext/thread/thread.c (get_array): check instance variables are initialized properly. [ruby-core:63826][Bug #10062] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread/thread.c: non-blocking push on SizedQueuenobu2014-07-171-0/+8
| | | | | | | * ext/thread/thread.c (rb_szqueue_push): add optional parameter, non_block defaulted to false. [ruby-core:63794] [Feature #10052] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_queue.rb: non-blocking pop testsnobu2014-07-171-0/+14
| | | | | | | | | | * test/thread/test_queue.rb (test_queue_pop_non_block): test for non-blocking pop. * test/thread/test_queue.rb (test_sized_queue_pop_non_block): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add timeoutnaruse2014-07-011-2/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/thread: fix leaked threadsnobu2014-05-262-0/+15
| | | | | | | * test/thread/test_{queue,sync}.rb: join work threads not to leak threads. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* marshal.c: undumpable hidden objectsnobu2014-03-262-0/+14
| | | | | | | * marshal.c (w_object): internal objects are not dumpable. [ruby-core:61677] [Bug #9674] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread.c: undumpablenobu2014-03-262-0/+21
| | | | | | | * ext/thread/thread.c (undumpable): ConditionVariable and Queue are not dumpable. [ruby-core:61677] [Bug #9674] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/thread: SizedQueue#max= wakes up waiters properlynormal2014-02-051-0/+7
| | | | | | | | | * ext/thread/thread.c (rb_szqueue_max_set): use correct queue and limit wakeups. [Bug #9343][ruby-core:60517] * test/thread/test_queue.rb (test_sized_queue_assign_max): test for bug git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread/thread.c: no dupnobu2014-01-222-0/+16
| | | | | | | * ext/thread/thread.c (Init_thread): ConditionVariable and Queue are not able to copy. [ruby-core:59961] [Bug #9440] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/thread/thread.c (rb_szqueue_clear): notify SZQUEUE_WAITERSglass2014-01-141-0/+22
| | | | | | | | | on SizedQueue#clear. [ruby-core:59462] [Bug #9342] * test/thread/test_queue.rb: add test. the patch is from Justin Collins. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/thread/thread.c (rb_szqueue_push): check GET_SZQUEUE_WAITERScharliesome2014-01-131-0/+23
| | | | | | | | | instead of GET_QUEUE_WAITERS to prevent deadlock. Patch by Eric Wong. [Bug #9302] [ruby-core:59324] * test/thread/test_queue.rb: add test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * variable.c (classname): the name of class that hasktsj2013-09-071-1/+4
| | | | | | | | | non class id should not be nil. This bug was introduced in r36577. * test/thread/test_cv.rb: test for change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * common.mk: use RUNRUBY instead of MINIRUBY because MINIRUBY can'tglass2013-09-061-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | require extension libraries. The patch is from nobu (Nobuyoshi Nakada). * ext/thread/extconf.rb: for build ext/thread/thread.c. * include/ruby/intern.h: ditto. * thread.c: ditto. * lib/thread.rb: removed and replaced by ext/thread/thread.c. * ext/thread/thread.c: Queue, SizedQueue and ConditionVariable implementations in C. This patch is based on patches from panaggio (Ricardo Panaggio) and funny_falcon (Yura Sokolov) and ko1 (Koichi Sasada). [ruby-core:31513] [Feature #3620] * test/thread/test_queue.rb (test_queue_thread_raise): add a test for ensuring that killed thread should be removed from waiting threads. It is based on a code by ko1 (Koichi Sasada). [ruby-core:45950] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces.nobu2013-03-111-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/thread.rb (Queue#push): return self.kosaki2013-03-101-0/+25
| | | | | | | | * lib/thread.rb (Queue#clear): ditto. * lib/thread.rb (SizedQueue#push): ditto. * test/thread/test_queue.rb: add tests for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/thread/test_queue.rb (TestQueue#test_thr_kill): reducekosaki2013-03-101-2/+3
| | | | | | | | | | | | | iterations from 2000 to 250. When running on uniprocessor systems, every th.kill needs TIME_QUANTUM_USEC time (i.e. 100msec on posix systems). Because, "r.read 1" is 3 steps operations that 1) release GVL 2) read 3) acquire gvl and (1) invoke context switch to main thread. and then, main thread's th.kill resume (1), but not (2). Thus read interrupt need TIME_QUANTUM_USEC. Then maximum iteration is 30sec/100msec = 300. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_thread.rb: move ConditionVariable related testkosaki2012-12-011-0/+188
| | | | | | | | | into test/thread/test_cv.rb. * test/thread/test_cv.rb: new file. * test/thread/test_cv.rb (test_condvar_empty_signal): new tests. * test/thread/test_cv.rb (test_condvar_empty_broadcast): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/thread.rb (ConditionVariable): use hash instead of array forkosaki2012-12-011-18/+0
| | | | | | | | | @waiters. * test/thread/test_queue.rb (test_sized_queue_and_wakeup): remove a test because @waiters no longer have a chance to duplicated. Now it's a hash. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/thread.rb (SizedQueue#pop): rewrite by using ConditionVariable.kosaki2012-11-301-1/+2
| | | | | | | | | | | | | | | * lib/thread.rb (SizedQueue#push): ditto. * lib/thread.rb (SizedQueue#max): ditto. * lib/thread.rb (Queue#pop): ditto. * lib/thread.rb (Queue#push): ditto. * lib/thread.rb (SizedQueue#num_waiting): adopt the above changes. * lib/thread.rb (SizedQueue#initialize): ditto. * lib/thread.rb (Queue#num_waiting): ditto. * lib/thread.rb (Queue#initialize): ditto. * test/thread/test_queue.rb (test_sized_queue_and_wakeup): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* envutil.rb: kill child process when timeoutshirosaki2012-09-291-1/+1
| | | | | | | | | | | * test/ruby/envutil.rb (EnvUtil#invoke_ruby): kill child process before Timeout::Error is raised. rmdir of mktmpdir fails with EACCES if child process is alive on Windows. * test/thread/test_queue.rb (TestQueue): increase timeout. This test takes long time on Windows XP. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/thread.rb (Queue#pop): Fixed double registration issue whenkosaki2012-09-091-0/+42
| | | | | | | | | | | mutex.sleep is interrupted. [Bug #5258] [ruby-dev:44448] * lib/thread.rb (SizedQueue#push): ditto. * test/thread/test_queue.rb (test_sized_queue_and_wakeup, test_queue_pop_interrupt, test_sized_queue_pop_interrupt, test_sized_queue_push_interrupt): new tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/sync.rb (Sync_m#sync_lock): Fixed wakeup/raise unsafe code.kosaki2012-09-091-0/+57
| | | | | | | | | | Patched by Masaki Matsushita. [Bug #5355] [ruby-dev:44521] * test/thread/test_sync.rb (test_sync_lock_and_wakeup, test_sync_upgrade_and_wakeup, test_sync_lock_and_raise): new test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* refine message for test_thr_kill.akr2011-12-231-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/thread/test_queue.rb (test_thr_kill): show the number of loopakr2011-12-231-12/+23
| | | | | | | | run when the test failed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Decrease timeout limit.naruse2011-12-221-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/thread/test_queue.rb (test_thr_kill): extend timeout.nagachika2011-12-181-2/+2
| | | | | | this test takes a long time at slow machine. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* The test added in r34034 needs to run thousands of times.naruse2011-12-141-10/+11
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add test for [Bug #5343] [ruby-core:39634]naruse2011-12-141-0/+17
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/thread.rb (SizedQueue#max=) raise ArgumentError if max is notnagachika2011-09-031-0/+18
| | | | | | | | | | positive number. patch by Masaki Matsushita. [ruby-dev:44449] [Bug #5259] * test/thread/test_queue.rb (test_sized_queue_initialize, test_sized_queue_assign_max): add tests for it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces.nobu2011-05-151-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/thread/test_queue.rb (TestQueue#grind): fix typos.kazu2010-04-161-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/thread.rb (Queue#push, #pop, SizedQueue#push, #pop): removemame2010-04-161-0/+38
code that kicks waiting thread twice, which caused race and deadlock. [ruby-core:25537] * test/thread/test_queue.rb: added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e