Event: Get rid of permanent_lock hack.
This commit is contained in:
parent
5e77e2e1de
commit
14cbbf4d9b
|
@ -26,7 +26,6 @@ public:
|
||||||
ResetType reset_type; ///< Current ResetType
|
ResetType reset_type; ///< Current ResetType
|
||||||
|
|
||||||
bool locked; ///< Event signal wait
|
bool locked; ///< Event signal wait
|
||||||
bool permanent_locked; ///< Hack - to set event permanent state (for easy passthrough)
|
|
||||||
std::string name; ///< Name of event (optional)
|
std::string name; ///< Name of event (optional)
|
||||||
|
|
||||||
ResultVal<bool> WaitSynchronization() override {
|
ResultVal<bool> WaitSynchronization() override {
|
||||||
|
@ -35,27 +34,13 @@ public:
|
||||||
AddWaitingThread(GetCurrentThread());
|
AddWaitingThread(GetCurrentThread());
|
||||||
Kernel::WaitCurrentThread(WAITTYPE_EVENT, this);
|
Kernel::WaitCurrentThread(WAITTYPE_EVENT, this);
|
||||||
}
|
}
|
||||||
if (reset_type != RESETTYPE_STICKY && !permanent_locked) {
|
if (reset_type != RESETTYPE_STICKY) {
|
||||||
locked = true;
|
locked = true;
|
||||||
}
|
}
|
||||||
return MakeResult<bool>(wait);
|
return MakeResult<bool>(wait);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Hackish function to set an events permanent lock state, used to pass through synch blocks
|
|
||||||
* @param handle Handle to event to change
|
|
||||||
* @param permanent_locked Boolean permanent locked value to set event
|
|
||||||
* @return Result of operation, 0 on success, otherwise error code
|
|
||||||
*/
|
|
||||||
ResultCode SetPermanentLock(Handle handle, const bool permanent_locked) {
|
|
||||||
Event* evt = g_handle_table.Get<Event>(handle).get();
|
|
||||||
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
|
||||||
|
|
||||||
evt->permanent_locked = permanent_locked;
|
|
||||||
return RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes whether an event is locked or not
|
* Changes whether an event is locked or not
|
||||||
* @param handle Handle to event to change
|
* @param handle Handle to event to change
|
||||||
|
@ -66,9 +51,8 @@ ResultCode SetEventLocked(const Handle handle, const bool locked) {
|
||||||
Event* evt = g_handle_table.Get<Event>(handle).get();
|
Event* evt = g_handle_table.Get<Event>(handle).get();
|
||||||
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
||||||
|
|
||||||
if (!evt->permanent_locked) {
|
evt->locked = locked;
|
||||||
evt->locked = locked;
|
|
||||||
}
|
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,16 +65,13 @@ ResultCode SignalEvent(const Handle handle) {
|
||||||
Event* evt = g_handle_table.Get<Event>(handle).get();
|
Event* evt = g_handle_table.Get<Event>(handle).get();
|
||||||
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
||||||
|
|
||||||
// Resume threads waiting for event to signal
|
|
||||||
bool event_caught = evt->ResumeAllWaitingThreads();
|
|
||||||
|
|
||||||
// If any thread is signalled awake by this event, assume the event was "caught" and reset
|
// If any thread is signalled awake by this event, assume the event was "caught" and reset
|
||||||
// the event. This will result in the next thread waiting on the event to block. Otherwise,
|
// the event. This will result in the next thread waiting on the event to block. Otherwise,
|
||||||
// the event will not be reset, and the next thread to call WaitSynchronization on it will
|
// the event will not be reset, and the next thread to call WaitSynchronization on it will
|
||||||
// not block. Not sure if this is correct behavior, but it seems to work.
|
// not block. Not sure if this is correct behavior, but it seems to work.
|
||||||
if (!evt->permanent_locked) {
|
// TODO(bunnei): Test how this works on hardware
|
||||||
evt->locked = event_caught;
|
evt->locked = evt->ResumeAllWaitingThreads();
|
||||||
}
|
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +84,8 @@ ResultCode ClearEvent(Handle handle) {
|
||||||
Event* evt = g_handle_table.Get<Event>(handle).get();
|
Event* evt = g_handle_table.Get<Event>(handle).get();
|
||||||
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
||||||
|
|
||||||
if (!evt->permanent_locked) {
|
evt->locked = true;
|
||||||
evt->locked = true;
|
|
||||||
}
|
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +103,6 @@ Event* CreateEvent(Handle& handle, const ResetType reset_type, const std::string
|
||||||
handle = Kernel::g_handle_table.Create(evt).ValueOr(INVALID_HANDLE);
|
handle = Kernel::g_handle_table.Create(evt).ValueOr(INVALID_HANDLE);
|
||||||
|
|
||||||
evt->locked = true;
|
evt->locked = true;
|
||||||
evt->permanent_locked = false;
|
|
||||||
evt->reset_type = evt->intitial_reset_type = reset_type;
|
evt->reset_type = evt->intitial_reset_type = reset_type;
|
||||||
evt->name = name;
|
evt->name = name;
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,6 @@ namespace Kernel {
|
||||||
*/
|
*/
|
||||||
ResultCode SetEventLocked(const Handle handle, const bool locked);
|
ResultCode SetEventLocked(const Handle handle, const bool locked);
|
||||||
|
|
||||||
/**
|
|
||||||
* Hackish function to set an events permanent lock state, used to pass through synch blocks
|
|
||||||
* @param handle Handle to event to change
|
|
||||||
* @param permanent_locked Boolean permanent locked value to set event
|
|
||||||
*/
|
|
||||||
ResultCode SetPermanentLock(Handle handle, const bool permanent_locked);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signals an event
|
* Signals an event
|
||||||
* @param handle Handle to event to signal
|
* @param handle Handle to event to signal
|
||||||
|
|
Loading…
Reference in New Issue