blob: 9cd64bf247230c2de9090c2ffdfc35887d6c1aee [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- PThreadCondition.h --------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Created by Greg Clayton on 6/16/07.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef __PThreadCondition_h__
15#define __PThreadCondition_h__
16
17#include <pthread.h>
18
Kate Stoneb9c1b512016-09-06 20:57:50 +000019class PThreadCondition {
Chris Lattner30fdc8d2010-06-08 16:52:24 +000020public:
Kate Stoneb9c1b512016-09-06 20:57:50 +000021 PThreadCondition() { ::pthread_cond_init(&m_condition, NULL); }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000022
Kate Stoneb9c1b512016-09-06 20:57:50 +000023 ~PThreadCondition() { ::pthread_cond_destroy(&m_condition); }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000024
Kate Stoneb9c1b512016-09-06 20:57:50 +000025 pthread_cond_t *Condition() { return &m_condition; }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000026
Kate Stoneb9c1b512016-09-06 20:57:50 +000027 int Broadcast() { return ::pthread_cond_broadcast(&m_condition); }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000028
Kate Stoneb9c1b512016-09-06 20:57:50 +000029 int Signal() { return ::pthread_cond_signal(&m_condition); }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000030
31protected:
Kate Stoneb9c1b512016-09-06 20:57:50 +000032 pthread_cond_t m_condition;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000033};
34
35#endif