From 4ce6781bd6727fca68d4c99337f47a75d849e5ab Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 21 Oct 2011 20:41:08 +0000 Subject: Merge QueuedEvent into Event. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3569 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/Event.hpp | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'src/server/Event.hpp') diff --git a/src/server/Event.hpp b/src/server/Event.hpp index e915631a..64e93b8b 100644 --- a/src/server/Event.hpp +++ b/src/server/Event.hpp @@ -34,14 +34,15 @@ class Engine; class Request; class ProcessContext; -/** Base class for all events (both realtime and QueuedEvent). +/** An event (command) to perform some action on Ingen. * - * This is for time-critical events like note ons. There is no non-realtime - * pre-execute method as in QueuedEvent's, any lookups etc need to be done in the - * realtime execute() method. + * Virtuall all operations on Ingen are implemented as events. An event has + * three distinct execution phases: * - * QueuedEvent extends this class with a pre_process() method for any work that needs - * to be done before processing in the realtime audio thread. + * 1) Pre-process: In a non-realtime thread, prepare event for execution + * 2) Execute: In the audio thread, execute (apply) event + * 3) Post-process: In a non-realtime thread, finalize event + * (e.g. clean up and send replies) * * \ingroup engine */ @@ -50,14 +51,17 @@ class Event : public Raul::Deletable public: virtual ~Event() {} - /** Execute this event in the audio thread (MUST be realtime safe). */ + /** Pre-process event before execution (non-realtime). */ + virtual void pre_process(); + + /** Execute this event in the audio thread (realtime). */ virtual void execute(ProcessContext& context); - /** Perform any actions after execution (ie send replies to commands) - * (no realtime requirements). */ + /** Post-process event after execution (non-realtime). */ virtual void post_process(); - inline SampleCount time() const { return _time; } + inline bool is_prepared() const { return _pre_processed; } + inline SampleCount time() const { return _time; } /** Get the next event in the event process list. */ Event* next() const { return _next.get(); } @@ -71,6 +75,16 @@ protected: , _request(request) , _time(time) , _error(0) // success + , _pre_processed(false) + , _executed(false) + {} + + /** Constructor for internal events only */ + explicit Event(Engine& engine) + : _engine(engine) + , _time(0) + , _error(0) // success + , _pre_processed(false) , _executed(false) {} @@ -79,6 +93,7 @@ protected: Raul::AtomicPtr _next; FrameTime _time; int _error; + bool _pre_processed; bool _executed; }; -- cgit v1.2.1