}
#endif
-MutexObserver::MutexObserver(ActorImpl* actor, activity::MutexImpl* mutex) : SimcallObserver(actor), mutex_(mutex) {}
-MutexTestObserver::MutexTestObserver(ActorImpl* actor, activity::MutexImpl* mutex) : MutexObserver(actor, mutex) {}
-
-MutexLockAsyncObserver::MutexLockAsyncObserver(ActorImpl* actor, activity::MutexImpl* mutex)
- : MutexObserver(actor, mutex)
+MutexObserver::MutexObserver(ActorImpl* actor, mc::Transition::Type type, activity::MutexImpl* mutex)
+ : SimcallObserver(actor), type_(type), mutex_(mutex)
{
}
-MutexLockWaitObserver::MutexLockWaitObserver(ActorImpl* actor, activity::MutexAcquisitionImplPtr synchro)
- : MutexObserver(actor, synchro->get_mutex().get()), synchro_(synchro)
+
+void MutexObserver::serialize(std::stringstream& stream) const
{
+ auto* owner = get_mutex()->get_owner();
+ stream << (short)type_ << ' ' << (uintptr_t)get_mutex() << ' ' << (owner != nullptr ? owner->get_pid() : -1);
}
-bool MutexLockWaitObserver::is_enabled()
+bool MutexObserver::is_enabled()
{
- return synchro_->test();
+ // Only wait can be disabled
+ return type_ != mc::Transition::Type::MUTEX_WAIT || mutex_->get_owner() == get_issuer();
}
} // namespace actor