openMSX
Public Types | Public Member Functions | List of all members
openmsx::EventDistributor Class Reference

#include <EventDistributor.hh>

Inheritance diagram for openmsx::EventDistributor:
Inheritance graph
[legend]
Collaboration diagram for openmsx::EventDistributor:
Collaboration graph
[legend]

Public Types

enum  Priority { OTHER, CONSOLE, HOTKEY, MSX }
 Priorities from high to low, higher priority listeners can block events for lower priority listeners. More...
 
typedef std::shared_ptr< const
Event
EventPtr
 

Public Member Functions

 EventDistributor (Reactor &reactor)
 
void registerEventListener (EventType type, EventListener &listener, Priority priority=OTHER)
 Registers a given object to receive certain events. More...
 
void unregisterEventListener (EventType type, EventListener &listener)
 Unregisters a previously registered event listener. More...
 
void distributeEvent (const EventPtr &event)
 Schedule the given event for delivery. More...
 
void deliverEvents ()
 This actually delivers the events. More...
 
bool sleep (unsigned us)
 Sleep for the specified amount of time, but return early when (another thread) called the distributeEvent() method. More...
 

Detailed Description

Definition at line 17 of file EventDistributor.hh.

Member Typedef Documentation

typedef std::shared_ptr<const Event> openmsx::EventDistributor::EventPtr

Definition at line 20 of file EventDistributor.hh.

Member Enumeration Documentation

Priorities from high to low, higher priority listeners can block events for lower priority listeners.

Enumerator
OTHER 
CONSOLE 
HOTKEY 
MSX 

Definition at line 25 of file EventDistributor.hh.

Constructor & Destructor Documentation

openmsx::EventDistributor::EventDistributor ( Reactor reactor)
explicit

Definition at line 14 of file EventDistributor.cc.

Member Function Documentation

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 80 of file EventDistributor.cc.

References openmsx::Semaphore::down(), openmsx::Thread::isMainThread(), and openmsx::Semaphore::up().

void openmsx::EventDistributor::distributeEvent ( const EventPtr 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 47 of file EventDistributor.cc.

References openmsx::Reactor::enterMainLoop(), openmsx::ScopedLock::release(), and openmsx::CondVar::signalAll().

Referenced by openmsx::MSXCPUInterface::doBreak(), openmsx::QuitCommand::execute(), openmsx::LDPixelRenderer::frameEnd(), openmsx::V9990PixelRenderer::frameEnd(), and openmsx::PixelRenderer::frameEnd().

void openmsx::EventDistributor::registerEventListener ( EventType  type,
EventListener listener,
Priority  priority = OTHER 
)
bool openmsx::EventDistributor::sleep ( unsigned  us)

Sleep for the specified amount of time, but return early when (another thread) called the distributeEvent() method.

Parameters
usAmount of time to sleep, in micro seconds.
Returns
true if we return because time has passed false if we return because distributeEvent() was called

Definition at line 119 of file EventDistributor.cc.

References openmsx::CondVar::waitTimeout().

void openmsx::EventDistributor::unregisterEventListener ( EventType  type,
EventListener listener 
)

The documentation for this class was generated from the following files: