jamesge commented on code in PR #2086:
URL: https://github.com/apache/brpc/pull/2086#discussion_r1086221251
##########
src/bthread/butex.cpp:
##########
@@ -137,27 +137,41 @@ static void wakeup_pthread(ButexPthreadWaiter* pw) {
bool erase_from_butex(ButexWaiter*, bool, WaiterState);
-int wait_pthread(ButexPthreadWaiter& pw, timespec* ptimeout) {
+int wait_pthread(ButexPthreadWaiter& pw, const timespec* abstime) {
+ timespec* ptimeout = NULL;
+ timespec timeout;
+ int64_t timeout_us = 0;
+ int rc;
+
while (true) {
- const int rc = futex_wait_private(&pw.sig, PTHREAD_NOT_SIGNALLED,
ptimeout);
- if (PTHREAD_NOT_SIGNALLED != pw.sig.load(butil::memory_order_acquire))
{
- // If `sig' is changed, wakeup_pthread() must be called and `pw'
- // is already removed from the butex.
- // Acquire fence makes this thread sees changes before wakeup.
- return rc;
+ if (abstime != NULL) {
+ timeout_us = butil::timespec_to_microseconds(*abstime) -
butil::gettimeofday_us();
+ timeout = butil::microseconds_to_timespec(timeout_us);
Review Comment:
这个timeout在下文中有用到么?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]