OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #ifndef CRASHPAD_UTIL_SYNCHRONIZATION_SEMAPHORE_H_ | 15 #ifndef CRASHPAD_UTIL_SYNCHRONIZATION_SEMAPHORE_H_ |
16 #define CRASHPAD_UTIL_SYNCHRONIZATION_SEMAPHORE_H_ | 16 #define CRASHPAD_UTIL_SYNCHRONIZATION_SEMAPHORE_H_ |
17 | 17 |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 | 19 |
20 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
21 #include <dispatch/dispatch.h> | 21 #include <dispatch/dispatch.h> |
| 22 #elif defined(OS_WIN) |
| 23 #include <windows.h> |
22 #else | 24 #else |
23 #include <semaphore.h> | 25 #include <semaphore.h> |
24 #endif | 26 #endif |
25 | 27 |
26 namespace crashpad { | 28 namespace crashpad { |
27 | 29 |
28 //! \brief An anonymous in-process counting sempahore. | 30 //! \brief An anonymous in-process counting sempahore. |
29 class Semaphore { | 31 class Semaphore { |
30 public: | 32 public: |
31 //! \brief Initializes the semaphore. | 33 //! \brief Initializes the semaphore. |
(...skipping 14 matching lines...) Expand all Loading... |
46 | 48 |
47 //! \brief Performs the signal (or “post”) operation on the semaphore. | 49 //! \brief Performs the signal (or “post”) operation on the semaphore. |
48 //! | 50 //! |
49 //! Atomically increments the value of the semaphore by 1. If the new value is | 51 //! Atomically increments the value of the semaphore by 1. If the new value is |
50 //! 0, a caller blocked in Wait() will be awakened. | 52 //! 0, a caller blocked in Wait() will be awakened. |
51 void Signal(); | 53 void Signal(); |
52 | 54 |
53 private: | 55 private: |
54 #if defined(OS_MACOSX) | 56 #if defined(OS_MACOSX) |
55 dispatch_semaphore_t semaphore_; | 57 dispatch_semaphore_t semaphore_; |
| 58 #elif defined(OS_WIN) |
| 59 HANDLE semaphore_; |
56 #else | 60 #else |
57 sem_t semaphore_; | 61 sem_t semaphore_; |
58 #endif | 62 #endif |
59 }; | 63 }; |
60 | 64 |
61 } // namespace crashpad | 65 } // namespace crashpad |
62 | 66 |
63 #endif // CRASHPAD_UTIL_SYNCHRONIZATION_SEMAPHORE_H_ | 67 #endif // CRASHPAD_UTIL_SYNCHRONIZATION_SEMAPHORE_H_ |
OLD | NEW |