// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors. // All rights reserved. // Code licensed under the BSD License. // http://www.anki3d.org/LICENSE #pragma once #include #include #include namespace anki { /// @addtogroup scene /// @{ /// This manager creates the events ands keeps track of them class EventManager { public: EventManager(); ~EventManager(); /// Create a new event /// @note It's thread-safe against itself. Can be called in Event::update. template T* newEvent(TArgs&&... args) { T* event = newInstance(SceneMemoryPool::getSingleton(), std::forward(args)...); LockGuard lock(m_eventsForRegistrationMtx); m_eventsForRegistration.pushBack(event); return event; } /// Update ANKI_INTERNAL void updateAllEvents(Second prevUpdateTime, Second crntTime); private: IntrusiveList m_events; IntrusiveList m_eventsForRegistration; SpinLock m_eventsForRegistrationMtx; static Bool assosiatedNodesMarkedForDeletion(const Event& e); }; /// @} } // end namespace anki