1 //===-- Support/ThreadSupport.h - Generic threading support -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines platform-agnostic interfaces that can be used to write
11 // multi-threaded programs. Autoconf is used to chose the correct
12 // implementation of these interfaces, or default to a non-thread-capable system
13 // if no matching system support is available.
15 //===----------------------------------------------------------------------===//
17 #ifndef SUPPORT_THREADSUPPORT_H
18 #define SUPPORT_THREADSUPPORT_H
20 #undef HAVE_PTHREAD_MUTEX_LOCK
22 #ifdef HAVE_PTHREAD_MUTEX_LOCK
23 #include "llvm/Support/ThreadSupport-PThreads.h"
25 #include "llvm/Support/ThreadSupport-NoSupport.h"
26 #endif // If no system support is available
29 /// MutexLocker - Instances of this class acquire a given Lock when
30 /// constructed and hold that lock until destruction.
34 MutexLocker(const MutexLocker &); // DO NOT IMPLEMENT
35 void operator=(const MutexLocker &); // DO NOT IMPLEMENT
37 MutexLocker(Mutex &m) : M(m) { M.acquire(); }
38 ~MutexLocker() { M.release(); }
42 #endif // SUPPORT_THREADSUPPORT_H