Title: [271101] trunk/Source/WTF
- Revision
- 271101
- Author
- [email protected]
- Date
- 2020-12-27 22:44:54 -0800 (Sun, 27 Dec 2020)
Log Message
Add a helper method to WTF::MachSemaphore to wait with a timeout duration
https://bugs.webkit.org/show_bug.cgi?id=220110
Reviewed by Sam Weinig.
Adds a helper method on the cross-process WTF::MachSemaphore class (to be utilized in webkit.org/b/219586).
* wtf/cocoa/MachSemaphore.cpp:
(WTF::MachSemaphore::waitFor):
This wraps a call to `semaphore_timedwait`, and converts the given time (in WTF::Seconds) into a
`mach_timespec_t`, which is an unsigned representing the number of seconds, along with another integer
representing the number of nanoseconds.
* wtf/cocoa/MachSemaphore.h:
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (271100 => 271101)
--- trunk/Source/WTF/ChangeLog 2020-12-28 04:41:00 UTC (rev 271100)
+++ trunk/Source/WTF/ChangeLog 2020-12-28 06:44:54 UTC (rev 271101)
@@ -1,3 +1,21 @@
+2020-12-27 Wenson Hsieh <[email protected]>
+
+ Add a helper method to WTF::MachSemaphore to wait with a timeout duration
+ https://bugs.webkit.org/show_bug.cgi?id=220110
+
+ Reviewed by Sam Weinig.
+
+ Adds a helper method on the cross-process WTF::MachSemaphore class (to be utilized in webkit.org/b/219586).
+
+ * wtf/cocoa/MachSemaphore.cpp:
+ (WTF::MachSemaphore::waitFor):
+
+ This wraps a call to `semaphore_timedwait`, and converts the given time (in WTF::Seconds) into a
+ `mach_timespec_t`, which is an unsigned representing the number of seconds, along with another integer
+ representing the number of nanoseconds.
+
+ * wtf/cocoa/MachSemaphore.h:
+
2020-12-23 Monson Shao <[email protected]>
[GTK][CMake] Forward missing header on Darwin
Modified: trunk/Source/WTF/wtf/cocoa/MachSemaphore.cpp (271100 => 271101)
--- trunk/Source/WTF/wtf/cocoa/MachSemaphore.cpp 2020-12-28 04:41:00 UTC (rev 271100)
+++ trunk/Source/WTF/wtf/cocoa/MachSemaphore.cpp 2020-12-28 06:44:54 UTC (rev 271101)
@@ -59,6 +59,12 @@
semaphore_wait(m_semaphore);
}
+void MachSemaphore::waitFor(Seconds timeout)
+{
+ auto seconds = timeout.secondsAs<unsigned>();
+ semaphore_timedwait(m_semaphore, { seconds, static_cast<clock_res_t>(timeout.nanosecondsAs<uint64_t>() - seconds * NSEC_PER_SEC) });
+}
+
MachSendRight MachSemaphore::createSendRight()
{
return MachSendRight::create(m_semaphore);
Modified: trunk/Source/WTF/wtf/cocoa/MachSemaphore.h (271100 => 271101)
--- trunk/Source/WTF/wtf/cocoa/MachSemaphore.h 2020-12-28 04:41:00 UTC (rev 271100)
+++ trunk/Source/WTF/wtf/cocoa/MachSemaphore.h 2020-12-28 06:44:54 UTC (rev 271101)
@@ -28,6 +28,7 @@
#include <mach/semaphore.h>
#include <wtf/MachSendRight.h>
#include <wtf/Noncopyable.h>
+#include <wtf/Seconds.h>
namespace WTF {
@@ -41,6 +42,7 @@
WTF_EXPORT_PRIVATE void signal();
WTF_EXPORT_PRIVATE void wait();
+ WTF_EXPORT_PRIVATE void waitFor(Seconds);
WTF_EXPORT_PRIVATE MachSendRight createSendRight();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes