From baeb3c1872a989b69eb89fae04f93c59b06f258e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 9 May 2012 01:14:30 +0000 Subject: Simply event interface design and make only one pre-process thread. This makes event pre-processing actually safe for multiple interfaces since multiple events will never be pre-processed simultaneously and the pre-process order is definitely the same as the execute order. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4323 a436a847-0d15-0410-975c-d299462d15a1 --- src/socket/SocketInterface.cpp | 43 +++++------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) (limited to 'src/socket/SocketInterface.cpp') diff --git a/src/socket/SocketInterface.cpp b/src/socket/SocketInterface.cpp index 430f0962..8b9aab66 100644 --- a/src/socket/SocketInterface.cpp +++ b/src/socket/SocketInterface.cpp @@ -24,21 +24,18 @@ #include "sratom/sratom.h" #include "SocketInterface.hpp" -#include "../server/Event.hpp" -#include "../server/PostProcessor.hpp" -#include "../server/ThreadManager.hpp" - #define LOG(s) s << "[SocketInterface] " namespace Ingen { namespace Socket { -SocketInterface::SocketInterface(Ingen::Shared::World& world, int conn) +SocketInterface::SocketInterface(Ingen::Shared::World& world, + Interface& iface, + int conn) : _world(world) - , _iface(*(Server::Engine*)world.local_engine().get(), *this) + , _iface(iface) , _inserter(NULL) , _msg_node(NULL) - , _event(NULL) , _conn(conn) { set_name("SocketInterface"); @@ -47,38 +44,11 @@ SocketInterface::SocketInterface(Ingen::Shared::World& world, int conn) SocketInterface::~SocketInterface() { - std::cerr << "SOCKET INTERFACE EXITING" << std::endl; stop(); join(); close(_conn); } -void -SocketInterface::event(Server::Event* ev) -{ - if (_event) { - std::cerr << "DUAL EVENTS" << std::endl; - return; - } - assert(!_event); - ev->pre_process(); - _event = ev; - _event->next(NULL); -} - -bool -SocketInterface::process(Server::PostProcessor& dest, - Server::ProcessContext& context, - bool limit) -{ - if (_event) { - _event->execute(context); - dest.append(_event, _event); - _event = NULL; - } - return (_conn != -1); -} - SerdStatus SocketInterface::set_base_uri(SocketInterface* iface, const SerdNode* uri_node) @@ -118,8 +88,6 @@ SocketInterface::write_statement(SocketInterface* iface, void SocketInterface::_run() { - Thread::set_context(Server::THREAD_PRE_PROCESS); - Sord::World* world = _world.rdf_world(); LV2_URID_Map* map = &_world.lv2_uri_map()->urid_map_feature()->urid_map; @@ -206,14 +174,13 @@ SocketInterface::_run() } fclose(f); - sord_inserter_free(_inserter); serd_reader_end_stream(reader); sratom_free(sratom); serd_reader_free(reader); sord_free(model); - _conn = -1; + delete this; } } // namespace Ingen -- cgit v1.2.1