summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2017-07-20 20:50:05 +0200
committerJulian Andres Klode <jak@debian.org>2017-07-20 20:50:05 +0200
commitb28636e54f682dc65aef169f201a34a8e2893369 (patch)
tree43beb2fbe7b87d1dc068ca05e6e49b0b311347e6 /apt-pkg/contrib
parente0204f0236697bdc1b2392be5e141de9ec0c184e (diff)
Use C++11 threading support instead of pthread
This makes the code easier to read.
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/error.cc28
1 files changed, 3 insertions, 25 deletions
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc
index 0233dfd59..e036f9aed 100644
--- a/apt-pkg/contrib/error.cc
+++ b/apt-pkg/contrib/error.cc
@@ -32,33 +32,11 @@
/*}}}*/
// Global Error Object /*{{{*/
-/* If the implementation supports posix threads then the accessor function
- is compiled to be thread safe otherwise a non-safe version is used. A
- Per-Thread error object is maintained in much the same manner as libc
- manages errno */
-#if defined(_POSIX_THREADS) && defined(HAVE_PTHREAD)
-#include <pthread.h>
-
-static pthread_key_t ErrorKey;
-static void ErrorDestroy(void *Obj) { delete (GlobalError *)Obj; };
-static void KeyAlloc() { pthread_key_create(&ErrorKey, ErrorDestroy); };
-
GlobalError *_GetErrorObj()
{
- static pthread_once_t Once = PTHREAD_ONCE_INIT;
- pthread_once(&Once, KeyAlloc);
-
- void *Res = pthread_getspecific(ErrorKey);
- if (Res == 0)
- pthread_setspecific(ErrorKey, Res = new GlobalError);
- return (GlobalError *)Res;
- }
-#else
- GlobalError *_GetErrorObj() {
- static GlobalError *Obj = new GlobalError;
- return Obj;
- }
-#endif
+ static thread_local GlobalError *Obj = new GlobalError;
+ return Obj;
+}
/*}}}*/
// GlobalError::GlobalError - Constructor /*{{{*/
GlobalError::GlobalError() : PendingFlag(false) {}