about summary refs log tree commit homepage
path: root/test.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-04-05 21:21:19 +0000
committerEric Wong <normalperson@yhbt.net>2013-04-05 22:30:36 +0000
commit7f87cbc2e5289f328c3278a991519068d8747374 (patch)
treebcc48402f5231c4f03b6916affe9c0e0c3c95c20 /test.rb
parent803b2c842701ca74d504b61e8d35fd801e00c614 (diff)
downloadmahoro-7f87cbc2e5289f328c3278a991519068d8747374.tar.gz
add optional thread-safety module
This can make Mahoro easier-to-use in multi-threaded apps
where magic concurrency is not required.  For real concurrency,
it is recommended users create per-thread Mahoro objects.
Diffstat (limited to 'test.rb')
-rwxr-xr-xtest.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test.rb b/test.rb
index 75e46d6..5c2c23d 100755
--- a/test.rb
+++ b/test.rb
@@ -2,6 +2,7 @@
 
 require 'test/unit'
 require 'mahoro'
+require 'mahoro/thread_safe'
 require 'pathname'
 
 class MahoroTestCase < Test::Unit::TestCase
@@ -90,6 +91,14 @@ class MahoroTestCase < Test::Unit::TestCase
                         Mahoro.compile "magic.sample\0"
                 end
         end
+
+        def test_thread_safe
+                before = @m.method(:file)
+                @m.extend(Mahoro::ThreadSafe)
+                @m.flags = Mahoro::NONE
+                assert_c_text(@m.file('mahoro.c'))
+                assert_not_equal(before.object_id, @m.method(:file).object_id)
+        end
 end
 
 # arch-tag: test