1 //===-- Support/ThreadSupport-PThreads.h - PThreads 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 pthreads implementations of the generic threading
11 // mechanisms. Users should never #include this file directly!
13 //===----------------------------------------------------------------------===//
15 // Users should never #include this file directly! As such, no include guards
18 #ifndef SUPPORT_THREADSUPPORT_H
19 #error "Code should not #include Support/ThreadSupport/PThreads.h directly!"
26 /// Mutex - This class allows user code to protect variables shared between
27 /// threads. It implements a "recursive" mutex, to simplify user code.
30 pthread_mutex_t mutex;
31 Mutex(const Mutex &); // DO NOT IMPLEMENT
32 void operator=(const Mutex &); // DO NOT IMPLEMENT
35 pthread_mutexattr_t Attr;
36 pthread_mutex_init(&mutex, &Attr);
38 ~Mutex() { pthread_mutex_destroy(&mutex); }
39 void acquire () { pthread_mutex_lock (&mutex); }
40 void release () { pthread_mutex_unlock (&mutex); }
42 } // end namespace llvm