fastthread 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/testtask'
4
4
  require 'rake/gempackagetask'
5
5
  require 'tools/rakehelp'
6
6
 
7
- GEM_VERSION="0.6.2"
7
+ GEM_VERSION="0.6.3"
8
8
 
9
9
  setup_extension('fastthread', 'fastthread')
10
10
 
@@ -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
- Mutex *mutex;
615
+ Data_Get_Struct(self, ConditionVariable, condvar);
589
616
 
590
617
  if ( CLASS_OF(mutex_v) != rb_cMutex ) {
591
- rb_raise(rb_eTypeError, "Not a Mutex");
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
  }
@@ -1,7 +1,6 @@
1
1
  require 'test/unit'
2
- if RUBY_PLATFORM == "java"
3
- require 'thread'
4
- else
2
+ require 'thread'
3
+ if RUBY_PLATFORM != "java"
5
4
  $:.unshift File.expand_path( File.join( File.dirname( __FILE__ ), "../ext/fastthread" ) )
6
5
  require 'fastthread'
7
6
  end
@@ -1,7 +1,6 @@
1
1
  require 'test/unit'
2
- if RUBY_PLATFORM == "java"
3
- require 'thread'
4
- else
2
+ require 'thread'
3
+ if RUBY_PLATFORM != "java"
5
4
  $:.unshift File.expand_path( File.join( File.dirname( __FILE__ ), "../ext/fastthread" ) )
6
5
  require 'fastthread'
7
6
  end
@@ -1,7 +1,6 @@
1
1
  require 'test/unit'
2
- if RUBY_PLATFORM == "java"
3
- require 'thread'
4
- else
2
+ require 'thread'
3
+ if RUBY_PLATFORM != "java"
5
4
  $:.unshift File.expand_path( File.join( File.dirname( __FILE__ ), "../ext/fastthread" ) )
6
5
  require 'fastthread'
7
6
  end
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.2
7
- date: 2007-01-18 00:00:00 -05:00
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
@@ -1,11 +0,0 @@
1
- require 'fastthread'
2
- require 'thread'
3
-
4
- mutex = Mutex.new
5
- condition = ConditionVariable.new
6
- t = Thread.new do
7
- mutex.lock
8
- condition.wait mutex
9
- end
10
- exit
11
-