#pragma once #include #include "../time/time.hpp" #include "../collections/Vector.hpp" #include #ifndef SPRAWL_EVENT_MAX_MULTIPLE_WAIT # define SPRAWL_EVENT_MAX_MULTIPLE_WAIT 256 #endif #if defined(_WIN32) # include typedef HANDLE EventType; #elif defined(__APPLE__) struct EventType { intptr_t ident; int queue; }; #else typedef int EventType; #endif namespace sprawl { namespace threading { class Event; } } class sprawl::threading::Event { public: typedef collections::Vector EventGroup; Event(); ~Event(); void Notify(); void Wait(); bool WaitFor(int64_t nanoseconds); bool WaitUntil(int64_t nanosecondTimestamp) { return WaitFor(nanosecondTimestamp - sprawl::time::Now(sprawl::time::Resolution::Nanoseconds)); } static Event* WaitMultiple(EventGroup& values); static Event* WaitMultipleFor(EventGroup& values, int64_t nanoseconds); static Event* WaitMultipleUntil(EventGroup& values, int64_t nanosecondTimestamp) { return WaitMultipleFor(values, nanosecondTimestamp - sprawl::time::Now(sprawl::time::Resolution::Nanoseconds)); } //TODO: Wait for multiple events static function EventType m_event; };