aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-30 18:22:54 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-30 18:22:54 +0100
commit8a36a1163bb36cd2fa0bdfe79a63e22be6595408 (patch)
treebcbf8d41d1ce73c72d1fa66c0f32e7e9df0bee0f
parent38ad8c655fef01fc054f835798e8662d412bff6d (diff)
downloadpaludis-8a36a1163bb36cd2fa0bdfe79a63e22be6595408.tar.gz
paludis-8a36a1163bb36cd2fa0bdfe79a63e22be6595408.tar.xz
Don't rely upon __thread
-rw-r--r--paludis/util/instantiation_policy-impl.hh14
1 files changed, 6 insertions, 8 deletions
diff --git a/paludis/util/instantiation_policy-impl.hh b/paludis/util/instantiation_policy-impl.hh
index d70d872..7c590f2 100644
--- a/paludis/util/instantiation_policy-impl.hh
+++ b/paludis/util/instantiation_policy-impl.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -72,21 +72,19 @@ template<typename OurType_>
OurType_ *
paludis::InstantiationPolicy<OurType_, paludis::instantiation_method::SingletonTag>::get_instance()
{
+ static Mutex m;
+ Lock l(m);
+
OurType_ * * i(_get_instance_ptr());
if (0 == *i)
{
- PALUDIS_TLS bool recursive(false);
+ static bool recursive(false);
if (recursive)
throw paludis::InternalError(PALUDIS_HERE, "Recursive instantiation");
Save<bool> save_recursive(&recursive, true);
- static Mutex m;
- Lock l(m);
-
- i = _get_instance_ptr();
- if (0 == *i)
- *i = new OurType_;
+ *i = new OurType_;
}
return *i;