diff options
author | David Robillard <d@drobilla.net> | 2008-08-19 18:51:06 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-08-19 18:51:06 +0000 |
commit | e16206982d074e62956de00eeef611478f01c430 (patch) | |
tree | 388bc6e5ad9220cf9cdedf865a2d45856f418ae4 /src/libs/client/ThreadedSigClientInterface.cpp | |
parent | 14764da12f3808da0c40b643ac8224716f060729 (diff) | |
download | ingen-e16206982d074e62956de00eeef611478f01c430.tar.gz ingen-e16206982d074e62956de00eeef611478f01c430.tar.bz2 ingen-e16206982d074e62956de00eeef611478f01c430.zip |
Preliminary connecting via HTTP in Gtk client.
Better handling of overflowed client event receive buffer.
Store fixes, complain only once about orphans, don't request an orphan parent over and over.
git-svn-id: http://svn.drobilla.net/lad/ingen@1447 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client/ThreadedSigClientInterface.cpp')
-rw-r--r-- | src/libs/client/ThreadedSigClientInterface.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/libs/client/ThreadedSigClientInterface.cpp b/src/libs/client/ThreadedSigClientInterface.cpp index 3b7af80c..ef95133b 100644 --- a/src/libs/client/ThreadedSigClientInterface.cpp +++ b/src/libs/client/ThreadedSigClientInterface.cpp @@ -17,7 +17,8 @@ #include "ThreadedSigClientInterface.hpp" #include <iostream> -using std::cerr; using std::endl; + +using namespace std; namespace Ingen { namespace Client { @@ -28,23 +29,19 @@ namespace Client { void ThreadedSigClientInterface::push_sig(Closure ev) { + _attached = true; if (!_enabled) return; bool success = false; - bool first = true; - - // (Very) slow busy-wait if the queue is full - // FIXME: Make this wait on a signal from process_sigs iff this happens while (!success) { - //printf("push %zu\n", _sigs.fill()); success = _sigs.push(ev); if (!success) { - if (first) { - cerr << "[ThreadedSigClientInterface] WARNING: (Client) event queue full. Waiting to try again..." << endl; - first = false; - } - usleep(200000); // 100 milliseconds (2* rate process_sigs is called) + cerr << "WARNING: Client event queue full. Waiting..." << endl; + _mutex.lock(); + _cond.wait(_mutex); + _mutex.unlock(); + cerr << "Queue drained, continuing" << endl; } } } @@ -58,18 +55,21 @@ ThreadedSigClientInterface::push_sig(Closure ev) bool ThreadedSigClientInterface::emit_signals() { - // Process a maximum of queue-size events, to prevent locking the GTK + // Process a limited number of events, to prevent locking the GTK // thread indefinitely while processing continually arriving events - const size_t limit = _sigs.capacity(); + size_t num_processed = 0; - while (!_sigs.empty() && num_processed++ < limit) { - //printf("emit %zu\n", _sigs.fill()); + while (!_sigs.empty() && num_processed++ < (_sigs.capacity() * 3 / 4)) { Closure& ev = _sigs.front(); - _sigs.pop(); ev(); ev.disconnect(); + _sigs.pop(); } + _mutex.lock(); + _cond.broadcast(); + _mutex.unlock(); + return true; } |