blob: 2f9060da02807b72c1140ee67d2c02a2be2a48ed [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- PThreadCondition.h --------------------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Chris Lattner30fdc8d2010-06-08 16:52:24 +00006//
7//===----------------------------------------------------------------------===//
8//
9// Created by Greg Clayton on 6/16/07.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef __PThreadCondition_h__
14#define __PThreadCondition_h__
15
16#include <pthread.h>
17
Kate Stoneb9c1b512016-09-06 20:57:50 +000018class PThreadCondition {
Chris Lattner30fdc8d2010-06-08 16:52:24 +000019public:
Kate Stoneb9c1b512016-09-06 20:57:50 +000020 PThreadCondition() { ::pthread_cond_init(&m_condition, NULL); }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000021
Kate Stoneb9c1b512016-09-06 20:57:50 +000022 ~PThreadCondition() { ::pthread_cond_destroy(&m_condition); }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000023
Kate Stoneb9c1b512016-09-06 20:57:50 +000024 pthread_cond_t *Condition() { return &m_condition; }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000025
Kate Stoneb9c1b512016-09-06 20:57:50 +000026 int Broadcast() { return ::pthread_cond_broadcast(&m_condition); }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000027
Kate Stoneb9c1b512016-09-06 20:57:50 +000028 int Signal() { return ::pthread_cond_signal(&m_condition); }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000029
30protected:
Kate Stoneb9c1b512016-09-06 20:57:50 +000031 pthread_cond_t m_condition;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000032};
33
34#endif