Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: util/synchronization/semaphore.h

Issue 909263002: Add Semaphore::TimedWait() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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,
(...skipping 26 matching lines...) Expand all
37 //! If the semaphore cannot be created, execution is terminated. 37 //! If the semaphore cannot be created, execution is terminated.
38 explicit Semaphore(int value); 38 explicit Semaphore(int value);
39 39
40 ~Semaphore(); 40 ~Semaphore();
41 41
42 //! \brief Performs the wait (or “procure”) operation on the semaphore. 42 //! \brief Performs the wait (or “procure”) operation on the semaphore.
43 //! 43 //!
44 //! Atomically decrements the value of the semaphore by 1. If the new value is 44 //! Atomically decrements the value of the semaphore by 1. If the new value is
45 //! negative, this function blocks and will not return until the semaphore’s 45 //! negative, this function blocks and will not return until the semaphore’s
46 //! value is incremented to 0 by Signal(). 46 //! value is incremented to 0 by Signal().
47 //!
48 //! \sa TimedWait()
47 void Wait(); 49 void Wait();
48 50
51 //! \brief Performs a timed wait (or “procure”) operation on the semaphore.
52 //!
53 //! \param[in] seconds The maximum number of seconds to wait for the operation
54 //! to complete.
55 //!
56 //! \return `false` if the wait timed out, `true` otherwise.
57 //!
58 //! This method is simlar to Wait(), except that the amount of time that it
59 //! blocks is limited.
60 bool TimedWait(double seconds);
61
49 //! \brief Performs the signal (or “post”) operation on the semaphore. 62 //! \brief Performs the signal (or “post”) operation on the semaphore.
50 //! 63 //!
51 //! Atomically increments the value of the semaphore by 1. If the new value is 64 //! Atomically increments the value of the semaphore by 1. If the new value is
52 //! 0, a caller blocked in Wait() will be awakened. 65 //! 0, a caller blocked in Wait() will be awakened.
53 void Signal(); 66 void Signal();
54 67
55 private: 68 private:
56 #if defined(OS_MACOSX) 69 #if defined(OS_MACOSX)
57 dispatch_semaphore_t semaphore_; 70 dispatch_semaphore_t semaphore_;
58 #elif defined(OS_WIN) 71 #elif defined(OS_WIN)
59 HANDLE semaphore_; 72 HANDLE semaphore_;
60 #else 73 #else
61 sem_t semaphore_; 74 sem_t semaphore_;
62 #endif 75 #endif
63 }; 76 };
64 77
65 } // namespace crashpad 78 } // namespace crashpad
66 79
67 #endif // CRASHPAD_UTIL_SYNCHRONIZATION_SEMAPHORE_H_ 80 #endif // CRASHPAD_UTIL_SYNCHRONIZATION_SEMAPHORE_H_
OLDNEW
« no previous file with comments | « no previous file | util/synchronization/semaphore.cc » ('j') | util/synchronization/semaphore_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698