Changes For Bug 352
[oota-llvm.git] / include / llvm / Support / ThreadSupport.h.in
1 //===-- Support/ThreadSupport.h - Generic threading support -----*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
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.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef SUPPORT_THREADSUPPORT_H
18 #define SUPPORT_THREADSUPPORT_H
19
20 #if @HAVE_PTHREAD_MUTEX_LOCK@
21 #include "llvm/Support/ThreadSupport-PThreads.h"
22 #else
23 #include "llvm/Support/ThreadSupport-NoSupport.h"
24 #endif // If no system support is available
25
26 namespace llvm {
27   /// MutexLocker - Instances of this class acquire a given Lock when
28   /// constructed and hold that lock until destruction.
29   ///
30   class MutexLocker {
31     Mutex &M;
32     MutexLocker(const MutexLocker &);    // DO NOT IMPLEMENT
33     void operator=(const MutexLocker &); // DO NOT IMPLEMENT
34   public:
35     MutexLocker(Mutex &m) : M(m) { M.acquire(); }
36     ~MutexLocker() { M.release(); }
37   };
38 }
39
40 #endif // SUPPORT_THREADSUPPORT_H