summaryrefslogtreecommitdiff
path: root/src/lib/encoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-11-05 23:21:07 +0000
committerCarl Hetherington <cth@carlh.net>2013-11-05 23:21:07 +0000
commite8a6e330570b817c6c5fdfef0f508f2cbe0168ef (patch)
tree22670f999547fc5f32f634d28a0ee971031c5611 /src/lib/encoder.cc
parente622a1400549cb7ac72c7352d2b7fbe1903d09dc (diff)
Add multiple threads for servers with multiple processing threads.
Diffstat (limited to 'src/lib/encoder.cc')
-rw-r--r--src/lib/encoder.cc21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index f1d2375b6..a442e64d0 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -72,16 +72,18 @@ Encoder::~Encoder ()
}
}
-/** Add a worker thread for a remote server. Caller must hold
+/** Add a worker thread for a each thread on a remote server. Caller must hold
* a lock on _mutex, or know that one is not currently required to
* safely modify _threads.
*/
void
-Encoder::add_worker_thread (ServerDescription d)
+Encoder::add_worker_threads (ServerDescription d)
{
- _threads.push_back (
- make_pair (d, new boost::thread (boost::bind (&Encoder::encoder_thread, this, d)))
- );
+ for (int i = 0; i < d.threads(); ++i) {
+ _threads.push_back (
+ make_pair (d, new boost::thread (boost::bind (&Encoder::encoder_thread, this, d)))
+ );
+ }
}
void
@@ -99,9 +101,7 @@ Encoder::process_begin ()
vector<ServerDescription> servers = Config::instance()->servers ();
for (vector<ServerDescription>::iterator i = servers.begin(); i != servers.end(); ++i) {
- for (int j = 0; j < i->threads (); ++j) {
- add_worker_thread (*i);
- }
+ add_worker_threads (*i);
}
_broadcast_thread = new boost::thread (boost::bind (&Encoder::broadcast_thread, this));
@@ -432,10 +432,7 @@ Encoder::listen_thread ()
}
if (i == _threads.end ()) {
- cout << "Adding a thread for " << ip << "\n";
- add_worker_thread (ServerDescription (ip, xml->number_child<int> ("Threads")));
- } else {
- cout << "Already know about " << ip << "\n";
+ add_worker_threads (ServerDescription (ip, xml->number_child<int> ("Threads")));
}
}
}