summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-05-03 02:56:09 +0000
committerDavid Robillard <d@drobilla.net>2012-05-03 02:56:09 +0000
commit9ae720fdc60d7e40b1b8be7c1133a57acb4e564c (patch)
tree99df6c7c38a850eba95bef35ed5a98f2a057d927
parent93fb77a658d4d78fc64f3b8b84ed28dd94b3e6f8 (diff)
downloadingen-9ae720fdc60d7e40b1b8be7c1133a57acb4e564c.tar.gz
ingen-9ae720fdc60d7e40b1b8be7c1133a57acb4e564c.tar.bz2
ingen-9ae720fdc60d7e40b1b8be7c1133a57acb4e564c.zip
Separate EventWriter interface from EventQueue.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4319 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/server/Engine.cpp3
-rw-r--r--src/server/EventQueue.cpp3
-rw-r--r--src/server/EventWriter.cpp (renamed from src/server/ServerInterfaceImpl.cpp)82
-rw-r--r--src/server/EventWriter.hpp (renamed from src/server/ServerInterfaceImpl.hpp)31
-rw-r--r--src/server/ingen_engine.cpp10
-rw-r--r--src/server/ingen_lv2.cpp20
-rw-r--r--src/server/wscript2
-rw-r--r--src/socket/ingen_socket_server.cpp14
8 files changed, 83 insertions, 82 deletions
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index 07c3663e..f793ad22 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -28,6 +28,7 @@
#include "ingen/shared/LV2URIMap.hpp"
#include "ingen/shared/Store.hpp"
#include "ingen/shared/URIs.hpp"
+
#include "BufferFactory.hpp"
#include "ClientBroadcaster.hpp"
#include "ControlBindings.hpp"
@@ -36,12 +37,12 @@
#include "EngineStore.hpp"
#include "Event.hpp"
#include "EventSource.hpp"
+#include "EventWriter.hpp"
#include "MessageContext.hpp"
#include "NodeFactory.hpp"
#include "PatchImpl.hpp"
#include "PostProcessor.hpp"
#include "ProcessContext.hpp"
-#include "ServerInterfaceImpl.hpp"
#include "ThreadManager.hpp"
using namespace std;
diff --git a/src/server/EventQueue.cpp b/src/server/EventQueue.cpp
index 8cb979ca..272273cd 100644
--- a/src/server/EventQueue.cpp
+++ b/src/server/EventQueue.cpp
@@ -29,11 +29,12 @@ EventQueue::EventQueue()
{
Thread::set_context(THREAD_PRE_PROCESS);
set_name("EventQueue");
+ start();
}
EventQueue::~EventQueue()
{
- Thread::stop();
+ stop();
}
/** Push an unprepared event onto the queue.
diff --git a/src/server/ServerInterfaceImpl.cpp b/src/server/EventWriter.cpp
index d3f151e7..4725835b 100644
--- a/src/server/ServerInterfaceImpl.cpp
+++ b/src/server/EventWriter.cpp
@@ -24,10 +24,10 @@
#include "Driver.hpp"
#include "Engine.hpp"
#include "EventQueue.hpp"
-#include "ServerInterfaceImpl.hpp"
+#include "EventWriter.hpp"
#include "events.hpp"
-#define LOG(s) s << "[ServerInterfaceImpl] "
+#define LOG(s) s << "[EventWriter] "
using namespace std;
using namespace Raul;
@@ -35,23 +35,21 @@ using namespace Raul;
namespace Ingen {
namespace Server {
-ServerInterfaceImpl::ServerInterfaceImpl(Engine& engine)
- : EventQueue()
- , _request_client(NULL)
+EventWriter::EventWriter(Engine& engine, EventSink& sink)
+ : _request_client(NULL)
+ , _sink(sink)
, _request_id(-1)
, _engine(engine)
, _in_bundle(false)
{
- start();
}
-ServerInterfaceImpl::~ServerInterfaceImpl()
+EventWriter::~EventWriter()
{
- stop();
}
SampleCount
-ServerInterfaceImpl::now() const
+EventWriter::now() const
{
// Exactly one cycle latency (some could run ASAP if we get lucky, but not always, and a slight
// constant latency is far better than jittery lower (average) latency
@@ -62,7 +60,7 @@ ServerInterfaceImpl::now() const
}
void
-ServerInterfaceImpl::set_response_id(int32_t id)
+EventWriter::set_response_id(int32_t id)
{
if (!_request_client) { // Kludge
_request_client = _engine.broadcaster()->client(
@@ -76,13 +74,13 @@ ServerInterfaceImpl::set_response_id(int32_t id)
// Bundle commands
void
-ServerInterfaceImpl::bundle_begin()
+EventWriter::bundle_begin()
{
_in_bundle = true;
}
void
-ServerInterfaceImpl::bundle_end()
+EventWriter::bundle_end()
{
_in_bundle = false;
}
@@ -90,30 +88,30 @@ ServerInterfaceImpl::bundle_end()
// Object commands
void
-ServerInterfaceImpl::put(const URI& uri,
- const Resource::Properties& properties,
- const Resource::Graph ctx)
+EventWriter::put(const URI& uri,
+ const Resource::Properties& properties,
+ const Resource::Graph ctx)
{
- event(new Events::SetMetadata(_engine, _request_client, _request_id, now(), true, ctx, uri, properties));
+ _sink.event(new Events::SetMetadata(_engine, _request_client, _request_id, now(), true, ctx, uri, properties));
}
void
-ServerInterfaceImpl::delta(const URI& uri,
- const Resource::Properties& remove,
- const Resource::Properties& add)
+EventWriter::delta(const URI& uri,
+ const Resource::Properties& remove,
+ const Resource::Properties& add)
{
- event(new Events::SetMetadata(_engine, _request_client, _request_id, now(), false, Resource::DEFAULT, uri, add, remove));
+ _sink.event(new Events::SetMetadata(_engine, _request_client, _request_id, now(), false, Resource::DEFAULT, uri, add, remove));
}
void
-ServerInterfaceImpl::move(const Path& old_path,
- const Path& new_path)
+EventWriter::move(const Path& old_path,
+ const Path& new_path)
{
- event(new Events::Move(_engine, _request_client, _request_id, now(), old_path, new_path));
+ _sink.event(new Events::Move(_engine, _request_client, _request_id, now(), old_path, new_path));
}
void
-ServerInterfaceImpl::del(const URI& uri)
+EventWriter::del(const URI& uri)
{
if (uri == "ingen:engine") {
if (_request_client) {
@@ -121,21 +119,21 @@ ServerInterfaceImpl::del(const URI& uri)
}
_engine.quit();
} else {
- event(new Events::Delete(_engine, _request_client, _request_id, now(), uri));
+ _sink.event(new Events::Delete(_engine, _request_client, _request_id, now(), uri));
}
}
void
-ServerInterfaceImpl::connect(const Path& tail_path,
- const Path& head_path)
+EventWriter::connect(const Path& tail_path,
+ const Path& head_path)
{
- event(new Events::Connect(_engine, _request_client, _request_id, now(), tail_path, head_path));
+ _sink.event(new Events::Connect(_engine, _request_client, _request_id, now(), tail_path, head_path));
}
void
-ServerInterfaceImpl::disconnect(const Path& src,
- const Path& dst)
+EventWriter::disconnect(const Path& src,
+ const Path& dst)
{
if (!Path::is_path(src) && !Path::is_path(dst)) {
LOG(Raul::error) << "Bad disconnect request " << src
@@ -143,36 +141,36 @@ ServerInterfaceImpl::disconnect(const Path& src,
return;
}
- event(new Events::Disconnect(_engine, _request_client, _request_id, now(),
+ _sink.event(new Events::Disconnect(_engine, _request_client, _request_id, now(),
Path(src.str()), Path(dst.str())));
}
void
-ServerInterfaceImpl::disconnect_all(const Path& patch_path,
- const Path& path)
+EventWriter::disconnect_all(const Path& patch_path,
+ const Path& path)
{
- event(new Events::DisconnectAll(_engine, _request_client, _request_id, now(), patch_path, path));
+ _sink.event(new Events::DisconnectAll(_engine, _request_client, _request_id, now(), patch_path, path));
}
void
-ServerInterfaceImpl::set_property(const URI& uri,
- const URI& predicate,
- const Atom& value)
+EventWriter::set_property(const URI& uri,
+ const URI& predicate,
+ const Atom& value)
{
if (uri == "ingen:engine" && predicate == "ingen:enabled"
&& value.type() == _engine.world()->forge().Bool) {
if (value.get_bool()) {
_engine.activate();
- event(new Events::Ping(_engine, _request_client, _request_id, now()));
+ _sink.event(new Events::Ping(_engine, _request_client, _request_id, now()));
} else {
- event(new Events::Deactivate(_engine, _request_client, _request_id, now()));
+ _sink.event(new Events::Deactivate(_engine, _request_client, _request_id, now()));
}
} else {
Resource::Properties remove;
remove.insert(make_pair(predicate, _engine.world()->uris()->wildcard));
Resource::Properties add;
add.insert(make_pair(predicate, value));
- event(new Events::SetMetadata(
+ _sink.event(new Events::SetMetadata(
_engine, _request_client, _request_id, now(), false, Resource::DEFAULT,
uri, add, remove));
}
@@ -181,9 +179,9 @@ ServerInterfaceImpl::set_property(const URI& uri,
// Requests //
void
-ServerInterfaceImpl::get(const URI& uri)
+EventWriter::get(const URI& uri)
{
- event(new Events::Get(_engine, _request_client, _request_id, now(), uri));
+ _sink.event(new Events::Get(_engine, _request_client, _request_id, now(), uri));
}
} // namespace Server
diff --git a/src/server/ServerInterfaceImpl.hpp b/src/server/EventWriter.hpp
index f34afaae..771d22f5 100644
--- a/src/server/ServerInterfaceImpl.hpp
+++ b/src/server/EventWriter.hpp
@@ -14,39 +14,35 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef INGEN_ENGINE_QUEUEDENGINEINTERFACE_HPP
-#define INGEN_ENGINE_QUEUEDENGINEINTERFACE_HPP
+#ifndef INGEN_ENGINE_EVENTWRITER_HPP
+#define INGEN_ENGINE_EVENTWRITER_HPP
#include <inttypes.h>
-#include <string>
#include <memory>
-#include "raul/SharedPtr.hpp"
+#include <string>
+
#include "ingen/Interface.hpp"
#include "ingen/Resource.hpp"
-#include "EventQueue.hpp"
+#include "raul/SharedPtr.hpp"
+
#include "types.hpp"
namespace Ingen {
namespace Server {
class Engine;
+class EventSink;
-/** A queued (preprocessed) event source / interface.
- *
- * This is both an Interface and an EventSource, calling Interface methods
- * will result in events in the EventSource.
+/** An Interface that creates and writes Events to an EventSink.
*
- * Responses occur through the event mechanism (which notified clients in
- * event post_process methods) and are related to an event by an integer ID.
- * If you do not register a request, you have no way of knowing if your calls
- * are successful.
+ * This is where Interface calls get turned into Events which are actually
+ * processed by the engine to do things.
*/
-class ServerInterfaceImpl : public EventQueue,
- public Interface
+class EventWriter : public Interface
{
public:
- explicit ServerInterfaceImpl(Engine& engine);
- virtual ~ServerInterfaceImpl();
+ explicit EventWriter(Engine& engine, EventSink& sink);
+ virtual ~EventWriter();
Raul::URI uri() const { return "http://drobilla.net/ns/ingen#internal"; }
@@ -91,6 +87,7 @@ public:
protected:
Interface* _request_client;
+ EventSink& _sink;
int32_t _request_id;
Engine& _engine;
bool _in_bundle; ///< True iff a bundle is currently being received
diff --git a/src/server/ingen_engine.cpp b/src/server/ingen_engine.cpp
index 84d38819..28659ec6 100644
--- a/src/server/ingen_engine.cpp
+++ b/src/server/ingen_engine.cpp
@@ -17,7 +17,8 @@
#include "ingen/shared/Module.hpp"
#include "ingen/shared/World.hpp"
#include "Engine.hpp"
-#include "ServerInterfaceImpl.hpp"
+#include "EventWriter.hpp"
+#include "EventQueue.hpp"
#include "util.hpp"
using namespace Ingen;
@@ -27,10 +28,11 @@ struct IngenEngineModule : public Ingen::Shared::Module {
Server::set_denormal_flags();
SharedPtr<Server::Engine> engine(new Server::Engine(world));
world->set_local_engine(engine);
- SharedPtr<Server::ServerInterfaceImpl> interface(
- new Server::ServerInterfaceImpl(*engine.get()));
+ SharedPtr<Server::EventQueue> queue(new Server::EventQueue());
+ SharedPtr<Server::EventWriter> interface(
+ new Server::EventWriter(*engine.get(), *queue.get()));
world->set_engine(interface);
- engine->add_event_source(interface);
+ engine->add_event_source(queue);
assert(world->local_engine() == engine);
}
};
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 21f1299d..94e7344d 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -45,10 +45,11 @@
#include "AudioBuffer.hpp"
#include "Driver.hpp"
#include "Engine.hpp"
+#include "EventQueue.hpp"
+#include "EventWriter.hpp"
#include "PatchImpl.hpp"
#include "PostProcessor.hpp"
#include "ProcessContext.hpp"
-#include "ServerInterfaceImpl.hpp"
#include "ThreadManager.hpp"
#define NS_INGEN "http://drobilla.net/ns/ingen#"
@@ -425,11 +426,12 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
plugin->main = new MainThread(engine);
plugin->main->set_name("Main");
- SharedPtr<Server::ServerInterfaceImpl> interface(
- new Server::ServerInterfaceImpl(*engine.get()));
+ SharedPtr<Server::EventQueue> queue(new Server::EventQueue());
+ SharedPtr<Server::EventWriter> interface(
+ new Server::EventWriter(*engine.get(), *queue.get()));
plugin->world->set_engine(interface);
- engine->add_event_source(interface);
+ engine->add_event_source(queue);
Raul::Thread::get().set_context(Server::THREAD_PRE_PROCESS);
Server::ThreadManager::single_threaded = true;
@@ -450,17 +452,15 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
engine->post_processor()->set_end_time(UINT_MAX);
- // TODO: Load only necessary plugins
- //plugin->world->engine()->get("ingen:plugins");
- interface->process(*engine->post_processor(), context, false);
+ queue->process(*engine->post_processor(), context, false);
engine->post_processor()->process();
plugin->world->parser()->parse_file(plugin->world,
plugin->world->engine().get(),
patch->filename);
- while (!interface->empty()) {
- interface->process(*engine->post_processor(), context, false);
+ while (!queue->empty()) {
+ queue->process(*engine->post_processor(), context, false);
engine->post_processor()->process();
}
@@ -493,7 +493,7 @@ ingen_activate(LV2_Handle instance)
{
IngenPlugin* me = (IngenPlugin*)instance;
me->world->local_engine()->activate();
- ((ServerInterfaceImpl*)me->world->engine().get())->start();
+ //((EventWriter*)me->world->engine().get())->start();
me->main->start();
}
diff --git a/src/server/wscript b/src/server/wscript
index faaeb38a..823583ba 100644
--- a/src/server/wscript
+++ b/src/server/wscript
@@ -14,6 +14,7 @@ def build(bld):
EngineStore.cpp
Event.cpp
EventQueue.cpp
+ EventWriter.cpp
GraphObjectImpl.cpp
InputPort.cpp
InternalPlugin.cpp
@@ -32,7 +33,6 @@ def build(bld):
PostProcessor.cpp
ProcessContext.cpp
ProcessSlave.cpp
- ServerInterfaceImpl.cpp
events/Connect.cpp
events/CreateNode.cpp
events/CreatePatch.cpp
diff --git a/src/socket/ingen_socket_server.cpp b/src/socket/ingen_socket_server.cpp
index 7ee20217..19257add 100644
--- a/src/socket/ingen_socket_server.cpp
+++ b/src/socket/ingen_socket_server.cpp
@@ -20,7 +20,8 @@
#include "ingen/shared/World.hpp"
#include "../server/Engine.hpp"
-#include "../server/ServerInterfaceImpl.hpp"
+#include "../server/EventWriter.hpp"
+#include "../server/EventQueue.hpp"
#include "SocketListener.hpp"
@@ -29,15 +30,16 @@ using namespace Ingen;
struct IngenSocketServerModule : public Ingen::Shared::Module {
void load(Ingen::Shared::World* world) {
Server::Engine* engine = (Server::Engine*)world->local_engine().get();
- SharedPtr<Server::ServerInterfaceImpl> interface(
- new Server::ServerInterfaceImpl(*engine));
- receiver = SharedPtr<Ingen::Socket::SocketListener>(
+ SharedPtr<Server::EventQueue> queue(new Server::EventQueue());
+ SharedPtr<Server::EventWriter> interface(
+ new Server::EventWriter(*engine, *queue.get()));
+ listener = SharedPtr<Ingen::Socket::SocketListener>(
new Ingen::Socket::SocketListener(*world, interface));
- engine->add_event_source(interface);
+ engine->add_event_source(queue);
}
- SharedPtr<Ingen::Socket::SocketListener> receiver;
+ SharedPtr<Ingen::Socket::SocketListener> listener;
};
extern "C" {