diff options
author | Tony Wasserka <neobrainx@gmail.com> | 2015-01-30 15:00:17 +0100 |
---|---|---|
committer | Tony Wasserka <neobrainx@gmail.com> | 2015-01-30 15:00:17 +0100 |
commit | 28702cbfeb1fe21109f8b1efa189785594319b78 (patch) | |
tree | 64e4b1ec43b7699fe1a6ab1be1c688b6d63c0d75 /src/core/hle/kernel/event.cpp | |
parent | Merge pull request #412 from purpasmart96/svc_table_cleanup (diff) | |
parent | Kernel: Mark all appropriate kernel objects as "final" (diff) | |
download | yuzu-28702cbfeb1fe21109f8b1efa189785594319b78.tar yuzu-28702cbfeb1fe21109f8b1efa189785594319b78.tar.gz yuzu-28702cbfeb1fe21109f8b1efa189785594319b78.tar.bz2 yuzu-28702cbfeb1fe21109f8b1efa189785594319b78.tar.lz yuzu-28702cbfeb1fe21109f8b1efa189785594319b78.tar.xz yuzu-28702cbfeb1fe21109f8b1efa189785594319b78.tar.zst yuzu-28702cbfeb1fe21109f8b1efa189785594319b78.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/kernel/event.cpp | 83 |
1 files changed, 21 insertions, 62 deletions
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp index a48125965..d9ad40c6a 100644 --- a/src/core/hle/kernel/event.cpp +++ b/src/core/hle/kernel/event.cpp @@ -14,78 +14,37 @@ namespace Kernel { -class Event : public WaitObject { -public: - std::string GetTypeName() const override { return "Event"; } - std::string GetName() const override { return name; } - - static const HandleType HANDLE_TYPE = HandleType::Event; - HandleType GetHandleType() const override { return HANDLE_TYPE; } - - ResetType intitial_reset_type; ///< ResetType specified at Event initialization - ResetType reset_type; ///< Current ResetType - - bool signaled; ///< Whether the event has already been signaled - std::string name; ///< Name of event (optional) - - bool ShouldWait() override { - return !signaled; - } - - void Acquire() override { - _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); - - // Release the event if it's not sticky... - if (reset_type != RESETTYPE_STICKY) - signaled = false; - } -}; - -ResultCode SignalEvent(const Handle handle) { - Event* evt = g_handle_table.Get<Event>(handle).get(); - if (evt == nullptr) - return InvalidHandle(ErrorModule::Kernel); - - evt->signaled = true; - evt->WakeupAllWaitingThreads(); - - return RESULT_SUCCESS; -} - -ResultCode ClearEvent(Handle handle) { - Event* evt = g_handle_table.Get<Event>(handle).get(); - if (evt == nullptr) - return InvalidHandle(ErrorModule::Kernel); +ResultVal<SharedPtr<Event>> Event::Create(ResetType reset_type, std::string name) { + SharedPtr<Event> evt(new Event); + // TOOD(yuriks): Don't create Handle (see Thread::Create()) + CASCADE_RESULT(auto unused, Kernel::g_handle_table.Create(evt)); evt->signaled = false; + evt->reset_type = evt->intitial_reset_type = reset_type; + evt->name = std::move(name); - return RESULT_SUCCESS; + return MakeResult<SharedPtr<Event>>(evt); } -/** - * Creates an event - * @param handle Reference to handle for the newly created mutex - * @param reset_type ResetType describing how to create event - * @param name Optional name of event - * @return Newly created Event object - */ -Event* CreateEvent(Handle& handle, const ResetType reset_type, const std::string& name) { - Event* evt = new Event; +bool Event::ShouldWait() { + return !signaled; +} - // TOOD(yuriks): Fix error reporting - handle = Kernel::g_handle_table.Create(evt).ValueOr(INVALID_HANDLE); +void Event::Acquire() { + _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); - evt->signaled = false; - evt->reset_type = evt->intitial_reset_type = reset_type; - evt->name = name; + // Release the event if it's not sticky... + if (reset_type != RESETTYPE_STICKY) + signaled = false; +} - return evt; +void Event::Signal() { + signaled = true; + WakeupAllWaitingThreads(); } -Handle CreateEvent(const ResetType reset_type, const std::string& name) { - Handle handle; - Event* evt = CreateEvent(handle, reset_type, name); - return handle; +void Event::Clear() { + signaled = false; } } // namespace |