summaryrefslogtreecommitdiffstats
path: root/src/engine/MessageContext.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-04-20 16:26:40 +0000
committerDavid Robillard <d@drobilla.net>2011-04-20 16:26:40 +0000
commit138a87e915ad3aff184730415105f94c874174bf (patch)
tree0d942bdddfdbcc3d969b4fce5592e770ab851b86 /src/engine/MessageContext.hpp
parent1f1758f4dda0ddaf01c0b1d3a756f9db8ddc979d (diff)
downloadingen-138a87e915ad3aff184730415105f94c874174bf.tar.gz
ingen-138a87e915ad3aff184730415105f94c874174bf.tar.bz2
ingen-138a87e915ad3aff184730415105f94c874174bf.zip
Rename Ingen::Engine to Ingen::Server (hopefully avoid odd name clases and fix #675).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3184 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/MessageContext.hpp')
-rw-r--r--src/engine/MessageContext.hpp114
1 files changed, 0 insertions, 114 deletions
diff --git a/src/engine/MessageContext.hpp b/src/engine/MessageContext.hpp
deleted file mode 100644
index ccdda448..00000000
--- a/src/engine/MessageContext.hpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/* This file is part of Ingen.
- * Copyright 2007-2011 David Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef INGEN_ENGINE_MESSAGECONTEXT_HPP
-#define INGEN_ENGINE_MESSAGECONTEXT_HPP
-
-#include <set>
-#include <glibmm/thread.h>
-#include "raul/Thread.hpp"
-#include "raul/Semaphore.hpp"
-#include "raul/AtomicPtr.hpp"
-#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
-#include "Context.hpp"
-#include "ProcessContext.hpp"
-#include "ThreadManager.hpp"
-
-namespace Ingen {
-namespace Engine {
-
-class NodeImpl;
-
-/** Context of a message_run() call.
- *
- * The message context is a non-hard-realtime thread used to execute things
- * that can take too long to execute in an audio thread, and do sloppy timed
- * event propagation and scheduling. Interface to plugins via the
- * LV2 contexts extension.
- *
- * \ingroup engine
- */
-class MessageContext : public Context, public Raul::Thread
-{
-public:
- explicit MessageContext(Engine& engine)
- : Context(engine, MESSAGE)
- , Raul::Thread("MessageContext")
- , _sem(0)
- , _requests(engine.event_queue_size())
- , _end_time(0)
- {
- Thread::set_context(THREAD_MESSAGE);
- }
-
- /** Schedule a message context run at a certain time.
- * Safe to call from either process thread or pre-process thread.
- */
- void run(NodeImpl* node, FrameTime time);
-
-protected:
- struct Request {
- Request(FrameTime t=0, NodeImpl* n=0) : time(t), node(n) {}
- FrameTime time;
- NodeImpl* node;
- };
-
-public:
- /** Signal the end of a cycle that has produced messages.
- * AUDIO THREAD ONLY.
- */
- inline void signal(ProcessContext& context) {
- ThreadManager::assert_thread(THREAD_PROCESS);
- const Request cycle_end_request(context.end(), NULL);
- _requests.write(sizeof(Request), &cycle_end_request);
- _sem.post();
- }
-
- /** Return true iff requests are pending. Safe from any thread. */
- inline bool has_requests() const {
- return _requests.read_space() >= sizeof(Request);
- }
-
-protected:
- /** Thread run method (wait for and execute requests from process thread */
- void _run();
-
- /** Execute a request (possibly enqueueing more requests) */
- void execute(const Request& req);
-
- Raul::Semaphore _sem;
- Raul::RingBuffer _requests;
- Glib::Mutex _mutex;
- Glib::Cond _cond;
- Request _non_rt_request;
-
- struct RequestEarlier {
- bool operator()(const Request& r1, const Request& r2) {
- return r1.time < r2.time;
- }
- };
-
- typedef std::set<Request, RequestEarlier> Queue;
- Queue _queue;
- FrameTime _end_time;
-};
-
-} // namespace Engine
-} // namespace Ingen
-
-#endif // INGEN_ENGINE_MESSAGECONTEXT_HPP
-