From 2773e08b5a9ddca42bc187f280daab139893ee04 Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 5 Dec 2009 22:35:15 +0000 Subject: [PATCH] default thread priority should be TP_low for readers and writers --- panda/src/net/config_net.cxx | 5 +++++ panda/src/net/config_net.h | 3 +++ panda/src/net/connectionReader.cxx | 4 ++-- panda/src/net/connectionWriter.cxx | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/panda/src/net/config_net.cxx b/panda/src/net/config_net.cxx index eb856273a7..d1f5f9d19f 100644 --- a/panda/src/net/config_net.cxx +++ b/panda/src/net/config_net.cxx @@ -109,6 +109,11 @@ ConfigVariableInt net_max_write_per_epoch "to minimize the impact of the networking layer on the other " "threads.")); +ConfigVariableEnum net_thread_priority +("net-thread-priority", TP_low, + PRC_DESC("The default thread priority when creating threaded readers " + "or writers.")); + //////////////////////////////////////////////////////////////////// // Function: init_libnet diff --git a/panda/src/net/config_net.h b/panda/src/net/config_net.h index 7ef19275df..4bcd278cac 100644 --- a/panda/src/net/config_net.h +++ b/panda/src/net/config_net.h @@ -19,6 +19,8 @@ #include "notifyCategoryProxy.h" #include "configVariableInt.h" #include "configVariableBool.h" +#include "configVariableEnum.h" +#include "threadPriority.h" // Configure variables for net package. @@ -31,6 +33,7 @@ extern double get_max_poll_cycle(); extern ConfigVariableInt net_max_read_per_epoch; extern ConfigVariableInt net_max_write_per_epoch; +extern ConfigVariableEnum net_thread_priority; extern EXPCL_PANDA_NET void init_libnet(); diff --git a/panda/src/net/connectionReader.cxx b/panda/src/net/connectionReader.cxx index 9bf311f21f..6f38dc8e73 100644 --- a/panda/src/net/connectionReader.cxx +++ b/panda/src/net/connectionReader.cxx @@ -129,7 +129,7 @@ ConnectionReader(ConnectionManager *manager, int num_threads) : _threads.push_back(thread); } for (i = 0; i < num_threads; i++) { - _threads[i]->start(TP_normal, true); + _threads[i]->start(net_thread_priority, true); } _manager->add_reader(this); @@ -849,7 +849,7 @@ thread_run(int thread_index) { while (!_shutdown) { SocketInfo *sinfo = - get_next_available_socket(false, thread_index); + get_next_available_socket(true, thread_index); if (sinfo != (SocketInfo *)NULL) { process_incoming_data(sinfo); Thread::consider_yield(); diff --git a/panda/src/net/connectionWriter.cxx b/panda/src/net/connectionWriter.cxx index 551aefc367..1363a64a03 100644 --- a/panda/src/net/connectionWriter.cxx +++ b/panda/src/net/connectionWriter.cxx @@ -81,7 +81,7 @@ ConnectionWriter(ConnectionManager *manager, int num_threads) : _threads.push_back(thread); } for (i = 0; i < num_threads; i++) { - _threads[i]->start(TP_normal, true); + _threads[i]->start(net_thread_priority, true); } _manager->add_writer(this);