better pstats tracking of loader task

This commit is contained in:
David Rose 2007-04-09 20:55:25 +00:00
parent ee3d5337d5
commit 601057c3a0
3 changed files with 19 additions and 2 deletions

View File

@ -1,4 +1,4 @@
#define LOCAL_LIBS putil express pandabase
#define LOCAL_LIBS putil express pandabase pstatclient
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
dtoolutil:c dtoolbase:c dtool:m prc:c

View File

@ -23,9 +23,14 @@
#include "eventParameter.h"
#include "mutexHolder.h"
#include "indent.h"
#include "pStatClient.h"
#include "pStatTimer.h"
TypeHandle AsyncTaskManager::_type_handle;
PStatCollector AsyncTaskManager::_task_pcollector("Task");
PStatCollector AsyncTaskManager::_wait_pcollector("Wait");
////////////////////////////////////////////////////////////////////
// Function: AsyncTaskManager::Constructor
// Access: Published
@ -406,9 +411,17 @@ void AsyncTaskManager::AsyncTaskManagerThread::
thread_main() {
MutexHolder holder(_manager->_lock);
while (_manager->_state != AsyncTaskManager::S_shutdown) {
_manager->service_one_task(this);
PStatClient::thread_tick(_manager->get_name());
{
PStatTimer timer(_task_pcollector);
_manager->service_one_task(this);
}
if (_manager->_active.empty() &&
_manager->_state != AsyncTaskManager::S_shutdown) {
PStatClient::thread_tick(_manager->get_name());
PStatTimer timer(_wait_pcollector);
_manager->_cvar.wait();
}
}

View File

@ -28,6 +28,7 @@
#include "conditionVarFull.h"
#include "pvector.h"
#include "pdeque.h"
#include "pStatCollector.h"
////////////////////////////////////////////////////////////////////
// Class : AsyncTaskManager
@ -100,6 +101,9 @@ protected:
int _num_tasks;
State _state;
static PStatCollector _task_pcollector;
static PStatCollector _wait_pcollector;
public:
static TypeHandle get_class_type() {
return _type_handle;