diff options
author | David Robillard <d@drobilla.net> | 2012-05-03 05:43:19 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-05-03 05:43:19 +0000 |
commit | 02dcc06a1675e936ef85714827accb20a9f2a94c (patch) | |
tree | e1980d770736b64b6652c4afed6f2a7bb3ba3858 /src/server | |
parent | 9ae720fdc60d7e40b1b8be7c1133a57acb4e564c (diff) | |
download | ingen-02dcc06a1675e936ef85714827accb20a9f2a94c.tar.gz ingen-02dcc06a1675e936ef85714827accb20a9f2a94c.tar.bz2 ingen-02dcc06a1675e936ef85714827accb20a9f2a94c.zip |
Work towards a proper server infrastructure with a thread per connection.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4320 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/Engine.cpp | 11 | ||||
-rw-r--r-- | src/server/Engine.hpp | 16 | ||||
-rw-r--r-- | src/server/EventQueue.cpp | 6 | ||||
-rw-r--r-- | src/server/EventQueue.hpp | 2 | ||||
-rw-r--r-- | src/server/EventSource.hpp | 5 | ||||
-rw-r--r-- | src/server/events/SetMetadata.hpp | 2 |
6 files changed, 24 insertions, 18 deletions
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index f793ad22..77630d54 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -237,8 +237,15 @@ Engine::process_events(ProcessContext& context) { ThreadManager::assert_thread(THREAD_PROCESS); - for (EventSources::iterator i = _event_sources.begin(); i != _event_sources.end(); ++i) - (*i)->process(*_post_processor, context); + EventSources::iterator i = _event_sources.begin(); + while (i != _event_sources.end()) { + EventSources::iterator next = i; + ++next; + if (!(*i)->process(*_post_processor, context)) { + _event_sources.erase(i); + } + i = next; + } } void diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp index 9a5d4f76..8e5f381f 100644 --- a/src/server/Engine.hpp +++ b/src/server/Engine.hpp @@ -62,24 +62,18 @@ public: virtual ~Engine(); + // EngineBase methods virtual bool activate(); - virtual void deactivate(); - virtual void quit(); - virtual bool main_iteration(); - - virtual void set_driver(SharedPtr<Driver> driver); - - virtual void add_event_source(SharedPtr<EventSource> source); - - virtual void process_events(ProcessContext& context); - virtual void register_client(const Raul::URI& uri, Interface* client); - virtual bool unregister_client(const Raul::URI& uri); + void set_driver(SharedPtr<Driver> driver); + void add_event_source(SharedPtr<EventSource> source); + void process_events(ProcessContext& context); + Ingen::Shared::World* world() const { return _world; } ClientBroadcaster* broadcaster() const { return _broadcaster; } diff --git a/src/server/EventQueue.cpp b/src/server/EventQueue.cpp index 272273cd..585eaa34 100644 --- a/src/server/EventQueue.cpp +++ b/src/server/EventQueue.cpp @@ -67,13 +67,13 @@ EventQueue::event(Event* const ev) * * Executed events will be pushed to @a dest. */ -void +bool EventQueue::process(PostProcessor& dest, ProcessContext& context, bool limit) { ThreadManager::assert_thread(THREAD_PROCESS); if (!_head.get()) - return; + return true; /* Limit the maximum number of queued events to process per cycle. This makes the process callback (more) realtime-safe by preventing being @@ -105,6 +105,8 @@ EventQueue::process(PostProcessor& dest, ProcessContext& context, bool limit) if (!next) _tail = NULL; } + + return true; } /** Pre-process a single event */ diff --git a/src/server/EventQueue.hpp b/src/server/EventQueue.hpp index a3567574..edd6c6b4 100644 --- a/src/server/EventQueue.hpp +++ b/src/server/EventQueue.hpp @@ -40,7 +40,7 @@ public: explicit EventQueue(); virtual ~EventQueue(); - void process(PostProcessor& dest, ProcessContext& context, bool limit=true); + bool process(PostProcessor& dest, ProcessContext& context, bool limit=true); inline bool unprepared_events() const { return _prepared_back.get(); } inline bool empty() const { return !_head.get(); } diff --git a/src/server/EventSource.hpp b/src/server/EventSource.hpp index 4425586d..65afece4 100644 --- a/src/server/EventSource.hpp +++ b/src/server/EventSource.hpp @@ -35,7 +35,10 @@ class EventSource public: virtual ~EventSource() {} - virtual void process(PostProcessor& dest, + /** Process events for a cycle. + * @return False iff this source is finished and should be removed. + */ + virtual bool process(PostProcessor& dest, ProcessContext& context, bool limit = true) = 0; }; diff --git a/src/server/events/SetMetadata.hpp b/src/server/events/SetMetadata.hpp index f906193c..e1bc0c55 100644 --- a/src/server/events/SetMetadata.hpp +++ b/src/server/events/SetMetadata.hpp @@ -96,7 +96,7 @@ private: typedef std::vector<SetPortValue*> SetEvents; - Event* _create_event; + Event* _create_event; SetEvents _set_events; std::vector<SpecialType> _types; std::vector<SpecialType> _remove_types; |