forked from chromiumembedded/java-cef
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcritical_wait.h
More file actions
50 lines (39 loc) · 970 Bytes
/
critical_wait.h
File metadata and controls
50 lines (39 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef JCEF_NATIVE_CRITICAL_WAIT_H_
#define JCEF_NATIVE_CRITICAL_WAIT_H_
#pragma once
#include "include/cef_task.h"
#if defined(OS_WIN)
#include <windows.h>
#define WAIT_MUTEX HANDLE
#define WAIT_COND HANDLE
#else
#include <pthread.h>
#define WAIT_MUTEX pthread_mutex_t
#define WAIT_COND pthread_cond_t
#endif
class CriticalLock {
public:
CriticalLock();
~CriticalLock();
void Lock();
void Unlock();
private:
friend class CriticalWait;
WAIT_MUTEX lock_;
};
class CriticalWait {
public:
explicit CriticalWait(CriticalLock* lock);
~CriticalWait();
void Wait();
bool Wait(unsigned int maxWaitMs);
void WakeUp();
CriticalLock* lock() { return lock_; }
private:
WAIT_COND cond_;
CriticalLock* lock_;
};
#endif // JCEF_NATIVE_CRITICAL_WAIT_H_