fastthread 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/ext/fastthread/fastthread.c +38 -7
- data/test/test_condvar.rb +2 -3
- data/test/test_mutex.rb +2 -3
- data/test/test_queue.rb +2 -3
- metadata +2 -3
- data/ext/fastthread/foo.rb +0 -11
data/Rakefile
CHANGED
data/ext/fastthread/fastthread.c
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* Optimized Ruby Mutex implementation, loosely based on thread.rb by
|
3
3
|
* Yukihiro Matsumoto <matz@ruby-lang.org>
|
4
4
|
*
|
5
|
-
* Copyright 2006 MenTaLguY <mental@rydia.net>
|
5
|
+
* Copyright 2006-2007 MenTaLguY <mental@rydia.net>
|
6
6
|
*
|
7
7
|
* This file is made available under the same terms as Ruby.
|
8
8
|
*/
|
@@ -577,6 +577,33 @@ wait_condvar(condvar, mutex)
|
|
577
577
|
lock_mutex(mutex);
|
578
578
|
}
|
579
579
|
|
580
|
+
static VALUE legacy_exclusive_unlock _((VALUE));
|
581
|
+
|
582
|
+
static VALUE
|
583
|
+
legacy_exclusive_unlock(mutex)
|
584
|
+
VALUE mutex;
|
585
|
+
{
|
586
|
+
return rb_funcall(mutex, rb_intern("exclusive_unlock"), 0);
|
587
|
+
}
|
588
|
+
|
589
|
+
typedef struct {
|
590
|
+
ConditionVariable *condvar;
|
591
|
+
VALUE mutex;
|
592
|
+
} legacy_wait_args;
|
593
|
+
|
594
|
+
static VALUE legacy_wait _((VALUE, legacy_wait_args *));
|
595
|
+
|
596
|
+
static VALUE
|
597
|
+
legacy_wait(unused, args)
|
598
|
+
VALUE unused;
|
599
|
+
legacy_wait_args *args;
|
600
|
+
{
|
601
|
+
push_list(&args->condvar->waiting, rb_thread_current());
|
602
|
+
rb_thread_stop();
|
603
|
+
rb_funcall(args->mutex, rb_intern("lock"), 0);
|
604
|
+
return Qnil;
|
605
|
+
}
|
606
|
+
|
580
607
|
static VALUE rb_condvar_wait _((VALUE, VALUE));
|
581
608
|
|
582
609
|
static VALUE
|
@@ -585,15 +612,19 @@ rb_condvar_wait(self, mutex_v)
|
|
585
612
|
VALUE mutex_v;
|
586
613
|
{
|
587
614
|
ConditionVariable *condvar;
|
588
|
-
|
615
|
+
Data_Get_Struct(self, ConditionVariable, condvar);
|
589
616
|
|
590
617
|
if ( CLASS_OF(mutex_v) != rb_cMutex ) {
|
591
|
-
|
618
|
+
/* interoperate with legacy mutex */
|
619
|
+
legacy_wait_args args;
|
620
|
+
args.condvar = condvar;
|
621
|
+
args.mutex = mutex_v;
|
622
|
+
rb_iterate(legacy_exclusive_unlock, mutex_v, legacy_wait, (VALUE)&args);
|
623
|
+
} else {
|
624
|
+
Mutex *mutex;
|
625
|
+
Data_Get_Struct(mutex_v, Mutex, mutex);
|
626
|
+
wait_condvar(condvar, mutex);
|
592
627
|
}
|
593
|
-
Data_Get_Struct(self, ConditionVariable, condvar);
|
594
|
-
Data_Get_Struct(mutex_v, Mutex, mutex);
|
595
|
-
|
596
|
-
wait_condvar(condvar, mutex);
|
597
628
|
|
598
629
|
return self;
|
599
630
|
}
|
data/test/test_condvar.rb
CHANGED
data/test/test_mutex.rb
CHANGED
data/test/test_queue.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: fastthread
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.6.
|
7
|
-
date: 2007-01-
|
6
|
+
version: 0.6.3
|
7
|
+
date: 2007-01-25 00:00:00 -05:00
|
8
8
|
summary: Optimized replacement for thread.rb primitives
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -36,7 +36,6 @@ files:
|
|
36
36
|
- test/test_queue.rb
|
37
37
|
- ext/fastthread/fastthread.c
|
38
38
|
- ext/fastthread/extconf.rb
|
39
|
-
- ext/fastthread/foo.rb
|
40
39
|
- tools/rakehelp.rb
|
41
40
|
test_files:
|
42
41
|
- test/test_all.rb
|