OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 return error; | 69 return error; |
70 } | 70 } |
71 private: | 71 private: |
72 std::mutex mutex; | 72 std::mutex mutex; |
73 std::condition_variable cv; | 73 std::condition_variable cv; |
74 bool isSet; | 74 bool isSet; |
75 std::string error; | 75 std::string error; |
76 }; | 76 }; |
77 | 77 |
78 void Sleep(int millis); | 78 void Sleep(int millis); |
79 | |
80 class Mutex | |
81 { | |
82 public: | |
83 #ifdef WIN32 | |
84 CRITICAL_SECTION nativeMutex; | |
85 #else | |
86 pthread_mutex_t nativeMutex; | |
87 #endif | |
88 | |
89 Mutex(); | |
90 ~Mutex(); | |
91 void Lock(); | |
92 void Unlock(); | |
93 }; | |
94 | |
95 class Lock | |
96 { | |
97 public: | |
98 Lock(Mutex& mutex); | |
99 ~Lock(); | |
100 | |
101 private: | |
102 Mutex& mutex; | |
103 }; | |
104 | |
105 class Thread | |
106 { | |
107 public: | |
108 explicit Thread(bool deleteSelfOnFinish = false); | |
109 virtual ~Thread(); | |
110 virtual void Run() = 0; | |
111 void Start(); | |
112 void Join(); | |
113 private: | |
114 static void CallRun(Thread* thread); | |
115 private: | |
116 #ifdef WIN32 | |
117 HANDLE nativeThread; | |
118 #else | |
119 pthread_t nativeThread; | |
120 #endif | |
121 bool m_deleteSelfOnFinish; | |
122 }; | |
123 } | 79 } |
124 | 80 |
125 #endif | 81 #endif |
OLD | NEW |