Implement KSynchronizationObject

This commit is contained in:
TuxSH
2018-11-04 18:51:27 +01:00
committed by Michael Scire
parent 1684e1d35c
commit 7fde5fbe40
6 changed files with 82 additions and 3 deletions

View File

@@ -0,0 +1,37 @@
#include <mesosphere/core/KSynchronizationObject.hpp>
#include <mesosphere/core/Result.hpp>
#include <mesosphere/core/KCoreContext.hpp>
#include <mesosphere/threading/KScheduler.hpp>
#include <mesosphere/threading/KThread.hpp>
#include <mutex>
namespace mesosphere
{
KSynchronizationObject::~KSynchronizationObject()
{
}
void KSynchronizationObject::Signal()
{
std::lock_guard criticalSection{KScheduler::GetCriticalSection()};
if (IsSignaled()) {
for (auto &&waiter : waiters) {
waiter->HandleSyncObjectSignaled(this);
}
}
}
KLinkedList<KThread *>::const_iterator KSynchronizationObject::AddWaiter(KThread &thread)
{
return waiters.insert(waiters.end(), &thread);
}
void KSynchronizationObject::RemoveWaiter(KLinkedList<KThread *>::const_iterator it)
{
waiters.erase(it);
}
}