From c6c2f7782e2270ee4684d2405376a186aa806fcd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 3 Dec 2010 17:27:53 -0800 Subject: add optional thread-safety on a per-object basis Thread-safety is useful sometimes and needless overhead otherwise. Default to whatever TDB upstream defaults to. --- lib/tdb.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/tdb.rb') diff --git a/lib/tdb.rb b/lib/tdb.rb index 2a75193..67114c9 100644 --- a/lib/tdb.rb +++ b/lib/tdb.rb @@ -1,2 +1,16 @@ # -*- encoding: binary -*- require 'tdb_ext' +class TDB + autoload :MT, 'tdb/mt' + + # makes the current TDB object thread-safe + def threadsafe! + extend MT + end + + # will return true when TDB::MT is included in TDB or the TDB + # object is extended by TDB + def threadsafe? + false + end +end -- cgit v1.2.3-24-ge0c7