Skip to content

Commit

Permalink
Fix ThreadGroup unit tests for cobalt.
Browse files Browse the repository at this point in the history
Change-Id: I4f2cd8e5bce0afe4f9135371ca85afb897f5dac9
  • Loading branch information
aee-google committed Jan 19, 2024
1 parent 012fd2e commit 86068e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion base/debug/leak_annotations.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// ANNOTATE_LEAKING_OBJECT_PTR(X): the heap object referenced by pointer X will
// be annotated as a leak.

#if defined(LEAK_SANITIZER) && !BUILDFLAG(IS_NACL)
#if defined(LEAK_SANITIZER) && !BUILDFLAG(IS_NACL) || defined(STARBOARD) && defined(ADDRESS_SANITIZER)

#include <sanitizer/lsan_interface.h>

Expand Down
23 changes: 14 additions & 9 deletions base/synchronization/condition_variable_starboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace base {

ConditionVariable::ConditionVariable(Lock* user_lock)
: user_mutex_(user_lock->lock_.native_handle())
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#if DCHECK_IS_ON()
,
user_lock_(user_lock)
#endif
Expand All @@ -40,31 +40,36 @@ ConditionVariable::~ConditionVariable() {
}

void ConditionVariable::Wait() {
internal::ScopedBlockingCallWithBaseSyncPrimitives scoped_blocking_call(FROM_HERE,
BlockingType::MAY_BLOCK);
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
absl::optional<internal::ScopedBlockingCallWithBaseSyncPrimitives>
scoped_blocking_call;
if (waiting_is_blocking_)
scoped_blocking_call.emplace(FROM_HERE, BlockingType::MAY_BLOCK);

#if DCHECK_IS_ON()
user_lock_->CheckHeldAndUnmark();
#endif
SbConditionVariableResult result =
SbConditionVariableWait(&condition_, user_mutex_);
DCHECK(SbConditionVariableIsSignaled(result));
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#if DCHECK_IS_ON()
user_lock_->CheckUnheldAndMark();
#endif
}

void ConditionVariable::TimedWait(const TimeDelta& max_time) {
internal::ScopedBlockingCallWithBaseSyncPrimitives scoped_blocking_call(FROM_HERE,
BlockingType::MAY_BLOCK);
absl::optional<internal::ScopedBlockingCallWithBaseSyncPrimitives>
scoped_blocking_call;
if (waiting_is_blocking_)
scoped_blocking_call.emplace(FROM_HERE, BlockingType::MAY_BLOCK);
SbTime duration = max_time.ToSbTime();

#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#if DCHECK_IS_ON()
user_lock_->CheckHeldAndUnmark();
#endif
SbConditionVariableResult result =
SbConditionVariableWaitTimed(&condition_, user_mutex_, duration);
DCHECK_NE(kSbConditionVariableFailed, result);
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#if DCHECK_IS_ON()
user_lock_->CheckUnheldAndMark();
#endif
}
Expand Down

0 comments on commit 86068e8

Please sign in to comment.