openMSX
|
#include <EventDistributor.hh>
Public Types | |
enum class | Priority { OTHER , HOTKEY_HIGH , IMGUI , HOTKEY_LOW , MSX , LOWEST } |
Priorities from high to low, higher priority listeners can block events for lower priority listeners. More... | |
Public Member Functions | |
EventDistributor (Reactor &reactor) | |
void | registerEventListener (EventType type, EventListener &listener, Priority priority=Priority::OTHER) |
Registers a given object to receive certain events. | |
void | unregisterEventListener (EventType type, EventListener &listener) |
Unregisters a previously registered event listener. | |
void | distributeEvent (Event &&event) |
Schedule the given event for delivery. | |
void | deliverEvents () |
This actually delivers the events. | |
bool | sleep (unsigned us) |
Sleep for the specified amount of time, but return early when (another thread) called the distributeEvent() method. | |
Friends | |
auto | operator<=> (Priority x, Priority y) |
Definition at line 18 of file EventDistributor.hh.
|
strong |
Priorities from high to low, higher priority listeners can block events for lower priority listeners.
Enumerator | |
---|---|
OTHER | |
HOTKEY_HIGH | |
IMGUI | |
HOTKEY_LOW | |
MSX | |
LOWEST |
Definition at line 24 of file EventDistributor.hh.
|
explicit |
Definition at line 15 of file EventDistributor.cc.
void openmsx::EventDistributor::deliverEvents | ( | ) |
This actually delivers the events.
It may only be called from the main loop in Reactor (and only from the main thread). Also see the distributeEvent() method.
Definition at line 67 of file EventDistributor.cc.
References openmsx::RTScheduler::execute(), openmsx::Reactor::getInputEventGenerator(), openmsx::Reactor::getInterpreter(), openmsx::Reactor::getRTScheduler(), openmsx::getType(), openmsx::Thread::isMainThread(), LOWEST, openmsx::InputEventGenerator::poll(), and openmsx::Interpreter::poll().
void openmsx::EventDistributor::distributeEvent | ( | Event && | event | ) |
Schedule the given event for delivery.
Actual delivery happens when the deliverEvents() method is called. Events are always in the main thread.
Definition at line 40 of file EventDistributor.cc.
References openmsx::Reactor::enterMainLoop(), and openmsx::getType().
Referenced by openmsx::MSXCPUInterface::doBreak(), openmsx::MSXMotherBoard::doReset(), openmsx::ExitCommand::execute(), openmsx::ImGuiManager::executeDelayed(), openmsx::LDPixelRenderer::frameEnd(), openmsx::PixelRenderer::frameEnd(), openmsx::V9990PixelRenderer::frameEnd(), openmsx::ImGuiManager::paintImGui(), openmsx::InputEventGenerator::poll(), openmsx::MSXMotherBoard::powerUp(), and openmsx::RS232Net::setRTS().
void openmsx::EventDistributor::registerEventListener | ( | EventType | type, |
EventListener & | listener, | ||
Priority | priority = Priority::OTHER |
||
) |
Registers a given object to receive certain events.
type | The type of the events you want to receive. |
listener | Listener that will be notified when an event arrives. |
priority | Listeners have a priority, higher priority listeners can block events for lower priority listeners. |
Definition at line 20 of file EventDistributor.cc.
References contains(), and ranges::upper_bound().
Referenced by openmsx::AfterCommand::AfterCommand(), openmsx::CassettePlayer::CassettePlayer(), openmsx::Display::Display(), openmsx::EventDelay::EventDelay(), openmsx::ImGuiManager::ImGuiManager(), openmsx::InputEventGenerator::InputEventGenerator(), openmsx::LaserdiscPlayer::LaserdiscPlayer(), openmsx::MidiInALSA::MidiInALSA(), openmsx::MidiInReader::MidiInReader(), openmsx::RealTime::RealTime(), openmsx::ReverseManager::ReverseManager(), openmsx::RS232Net::RS232Net(), openmsx::RS232Tester::RS232Tester(), openmsx::Video9000::Video9000(), and openmsx::VisibleSurface::VisibleSurface().
bool openmsx::EventDistributor::sleep | ( | unsigned | us | ) |
Sleep for the specified amount of time, but return early when (another thread) called the distributeEvent() method.
us | Amount of time to sleep, in micro seconds. |
Definition at line 112 of file EventDistributor.cc.
void openmsx::EventDistributor::unregisterEventListener | ( | EventType | type, |
EventListener & | listener | ||
) |
Unregisters a previously registered event listener.
type | The type of the events the listener should no longer receive. |
listener | Listener to unregister. |
Definition at line 32 of file EventDistributor.cc.
References rfind_unguarded().
Referenced by openmsx::AfterCommand::~AfterCommand(), openmsx::CassettePlayer::~CassettePlayer(), openmsx::CliConnection::~CliConnection(), openmsx::Display::~Display(), openmsx::EventDelay::~EventDelay(), openmsx::FilePool::~FilePool(), openmsx::ImGuiManager::~ImGuiManager(), openmsx::InputEventGenerator::~InputEventGenerator(), openmsx::LaserdiscPlayer::~LaserdiscPlayer(), openmsx::MidiInALSA::~MidiInALSA(), openmsx::MidiInReader::~MidiInReader(), openmsx::RealTime::~RealTime(), openmsx::ReverseManager::~ReverseManager(), openmsx::RS232Net::~RS232Net(), openmsx::RS232Tester::~RS232Tester(), openmsx::Video9000::~Video9000(), and openmsx::VisibleSurface::~VisibleSurface().
Definition at line 32 of file EventDistributor.hh.