This source file includes following definitions.
- CalledOnValidSequencedThread
- DetachFromSequence
- EnsureSequenceTokenAssigned
#include "base/sequence_checker_impl.h"
namespace base {
SequenceCheckerImpl::SequenceCheckerImpl()
: sequence_token_assigned_(false) {
AutoLock auto_lock(lock_);
EnsureSequenceTokenAssigned();
}
SequenceCheckerImpl::~SequenceCheckerImpl() {}
bool SequenceCheckerImpl::CalledOnValidSequencedThread() const {
AutoLock auto_lock(lock_);
EnsureSequenceTokenAssigned();
if (!sequence_token_.IsValid())
return thread_checker_.CalledOnValidThread();
return sequence_token_.Equals(
SequencedWorkerPool::GetSequenceTokenForCurrentThread());
}
void SequenceCheckerImpl::DetachFromSequence() {
AutoLock auto_lock(lock_);
thread_checker_.DetachFromThread();
sequence_token_assigned_ = false;
sequence_token_ = SequencedWorkerPool::SequenceToken();
}
void SequenceCheckerImpl::EnsureSequenceTokenAssigned() const {
lock_.AssertAcquired();
if (sequence_token_assigned_)
return;
sequence_token_assigned_ = true;
sequence_token_ = SequencedWorkerPool::GetSequenceTokenForCurrentThread();
}
}