if (owner_ != nullptr) {
/* Somebody is using the mutex; register the acquisition */
- sleeping_.push_back(res);
+ ongoing_acquisitions_.push_back(res);
} else {
owner_ = issuer;
}
xbt_assert(issuer == owner_, "Cannot release that mutex: you're not the owner. %s is (pid:%ld).",
owner_ != nullptr ? owner_->get_cname() : "(nobody)", owner_ != nullptr ? owner_->get_pid() : -1);
- if (not sleeping_.empty()) {
+ if (not ongoing_acquisitions_.empty()) {
/* Give the ownership to the first waiting actor */
- auto acq = sleeping_.front();
- sleeping_.pop_front();
+ auto acq = ongoing_acquisitions_.front();
+ ongoing_acquisitions_.pop_front();
owner_ = acq->get_issuer();
if (acq == owner_->waiting_synchro_)
std::atomic_int_fast32_t refcount_{1};
s4u::Mutex piface_;
actor::ActorImpl* owner_ = nullptr;
- // List of sleeping actors:
- std::deque<MutexAcquisitionImplPtr> sleeping_;
+ std::deque<MutexAcquisitionImplPtr> ongoing_acquisitions_;
static unsigned next_id_;
- unsigned id_;
+ unsigned id_ = next_id_++;
friend MutexAcquisitionImpl;
public:
- MutexImpl() : piface_(this), id_(next_id_++) {}
+ MutexImpl() : piface_(this) {}
MutexImpl(MutexImpl const&) = delete;
MutexImpl& operator=(MutexImpl const&) = delete;
} else { // we have to report that timeout
/* Remove myself from the list of interested parties */
auto issuer = get_issuer();
- auto it = std::find_if(semaphore_->sleeping_.begin(), semaphore_->sleeping_.end(),
+ auto it = std::find_if(semaphore_->ongoing_acquisitions_.begin(), semaphore_->ongoing_acquisitions_.end(),
[issuer](SemAcquisitionImplPtr acqui) { return acqui->get_issuer() == issuer; });
- xbt_assert(it != semaphore_->sleeping_.end(), "Cannot find myself in the waiting queue that I have to leave");
- semaphore_->sleeping_.erase(it);
+ xbt_assert(it != semaphore_->ongoing_acquisitions_.end(),
+ "Cannot find myself in the waiting queue that I have to leave");
+ semaphore_->ongoing_acquisitions_.erase(it);
/* Return to the englobing simcall that the wait_for timeouted */
auto* observer = dynamic_cast<kernel::actor::SemAcquireSimcall*>(issuer->simcall_.observer_);
if (value_ <= 0) {
/* No free token in the semaphore; register the acquisition */
- sleeping_.push_back(res);
+ ongoing_acquisitions_.push_back(res);
} else {
value_--;
res->granted_ = true;
{
XBT_DEBUG("Sem release semaphore %p", this);
- if (not sleeping_.empty()) {
+ if (not ongoing_acquisitions_.empty()) {
/* Release the first waiting actor */
- auto acqui = sleeping_.front();
- sleeping_.pop_front();
+ auto acqui = ongoing_acquisitions_.front();
+ ongoing_acquisitions_.pop_front();
acqui->granted_ = true;
if (acqui == acqui->get_issuer()->waiting_synchro_)
std::atomic_int_fast32_t refcount_{1};
s4u::Semaphore piface_;
unsigned int value_;
- std::deque<SemAcquisitionImplPtr> sleeping_; /* ongoing acquisitions */
+ std::deque<SemAcquisitionImplPtr> ongoing_acquisitions_;
friend SemAcquisitionImpl;
bool would_block() const { return (value_ == 0); }
unsigned int get_capacity() const { return value_; }
- bool is_used() const { return not sleeping_.empty(); }
+ bool is_used() const { return not ongoing_acquisitions_.empty(); }
friend void intrusive_ptr_add_ref(SemaphoreImpl* sem)
{