mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -04:00
fix pstats mutex leaking
This commit is contained in:
parent
a9f3242305
commit
574403a39f
@ -26,7 +26,9 @@
|
||||
#include "pStatCollector.h"
|
||||
#include "geomEnums.h"
|
||||
#include "lightReMutex.h"
|
||||
#include "lightReMutexHolder.h"
|
||||
#include "lightMutex.h"
|
||||
#include "lightMutexHolder.h"
|
||||
#include "config_pgraph.h"
|
||||
#include "deletedChain.h"
|
||||
#include "simpleHashMap.h"
|
||||
|
@ -148,9 +148,10 @@ do_acquire(Thread *current_thread) {
|
||||
// In this case, it's not a real mutex. Just watch it go by.
|
||||
MissedThreads::iterator mi = _missed_threads.insert(MissedThreads::value_type(current_thread, 0)).first;
|
||||
if ((*mi).second == 0) {
|
||||
thread_cat.info()
|
||||
<< *current_thread << " not stopped by " << *this << " (held by "
|
||||
<< *_locking_thread << ")\n";
|
||||
ostringstream ostr;
|
||||
ostr << *current_thread << " not stopped by " << *this << " (held by "
|
||||
<< *_locking_thread << ")\n";
|
||||
nassert_raise(ostr.str());
|
||||
} else {
|
||||
if (!_allow_recursion) {
|
||||
ostringstream ostr;
|
||||
|
@ -75,7 +75,7 @@ get_max_rate() const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int PStatClient::
|
||||
get_num_collectors() const {
|
||||
LightReMutexHolder holder(_lock);
|
||||
ReMutexHolder holder(_lock);
|
||||
return _num_collectors;
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ get_collector_def(int index) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int PStatClient::
|
||||
get_num_threads() const {
|
||||
LightReMutexHolder holder(_lock);
|
||||
ReMutexHolder holder(_lock);
|
||||
return _num_threads;
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ resume_after_pause() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool PStatClient::
|
||||
client_connect(string hostname, int port) {
|
||||
LightReMutexHolder holder(_lock);
|
||||
ReMutexHolder holder(_lock);
|
||||
client_disconnect();
|
||||
return get_impl()->client_connect(hostname, port);
|
||||
}
|
||||
@ -261,7 +261,7 @@ has_impl() const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PStatClientImpl *PStatClient::
|
||||
get_impl() {
|
||||
LightReMutexHolder holder(_lock);
|
||||
ReMutexHolder holder(_lock);
|
||||
if (_impl == (PStatClientImpl *)NULL) {
|
||||
_impl = new PStatClientImpl(this);
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ get_collector_fullname(int index) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PStatThread PStatClient::
|
||||
get_thread(int index) const {
|
||||
LightReMutexHolder holder(_lock);
|
||||
ReMutexHolder holder(_lock);
|
||||
nassertr(index >= 0 && index < _num_threads, PStatThread());
|
||||
return PStatThread((PStatClient *)this, index);
|
||||
}
|
||||
@ -370,7 +370,7 @@ thread_tick(const string &sync_name) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PStatClient::
|
||||
client_main_tick() {
|
||||
LightReMutexHolder holder(_lock);
|
||||
ReMutexHolder holder(_lock);
|
||||
if (has_impl()) {
|
||||
if (!_impl->client_is_connected()) {
|
||||
client_disconnect();
|
||||
@ -400,7 +400,7 @@ client_main_tick() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PStatClient::
|
||||
client_thread_tick(const string &sync_name) {
|
||||
LightReMutexHolder holder(_lock);
|
||||
ReMutexHolder holder(_lock);
|
||||
|
||||
if (has_impl()) {
|
||||
MultiThingsByName::const_iterator ni =
|
||||
@ -423,7 +423,7 @@ client_thread_tick(const string &sync_name) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PStatClient::
|
||||
client_disconnect() {
|
||||
LightReMutexHolder holder(_lock);
|
||||
ReMutexHolder holder(_lock);
|
||||
if (has_impl()) {
|
||||
_impl->client_disconnect();
|
||||
delete _impl;
|
||||
@ -484,7 +484,7 @@ get_global_pstats() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PStatCollector PStatClient::
|
||||
make_collector_with_relname(int parent_index, string relname) {
|
||||
LightReMutexHolder holder(_lock);
|
||||
ReMutexHolder holder(_lock);
|
||||
|
||||
if (relname.empty()) {
|
||||
relname = "Unnamed";
|
||||
@ -524,7 +524,7 @@ make_collector_with_relname(int parent_index, string relname) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PStatCollector PStatClient::
|
||||
make_collector_with_name(int parent_index, const string &name) {
|
||||
LightReMutexHolder holder(_lock);
|
||||
ReMutexHolder holder(_lock);
|
||||
|
||||
nassertr(parent_index >= 0 && parent_index < _num_collectors,
|
||||
PStatCollector());
|
||||
@ -593,7 +593,7 @@ do_get_current_thread() const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PStatThread PStatClient::
|
||||
make_thread(Thread *thread) {
|
||||
LightReMutexHolder holder(_lock);
|
||||
ReMutexHolder holder(_lock);
|
||||
return do_make_thread(thread);
|
||||
}
|
||||
|
||||
@ -1144,7 +1144,7 @@ activate_hook(Thread *thread) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PStatClient::Collector::
|
||||
make_def(const PStatClient *client, int this_index) {
|
||||
LightReMutexHolder holder(client->_lock);
|
||||
ReMutexHolder holder(client->_lock);
|
||||
if (_def == (PStatCollectorDef *)NULL) {
|
||||
_def = new PStatCollectorDef(this_index, _name);
|
||||
if (_parent_index != this_index) {
|
||||
|
@ -20,9 +20,9 @@
|
||||
#include "pStatFrameData.h"
|
||||
#include "pStatClientImpl.h"
|
||||
#include "pStatCollectorDef.h"
|
||||
#include "lightReMutex.h"
|
||||
#include "reMutex.h"
|
||||
#include "lightMutex.h"
|
||||
#include "lightReMutexHolder.h"
|
||||
#include "reMutexHolder.h"
|
||||
#include "lightMutexHolder.h"
|
||||
#include "pmap.h"
|
||||
#include "thread.h"
|
||||
@ -144,7 +144,7 @@ private:
|
||||
|
||||
private:
|
||||
// This mutex protects everything in this class.
|
||||
LightReMutex _lock;
|
||||
ReMutex _lock;
|
||||
|
||||
typedef pmap<string, int> ThingsByName;
|
||||
typedef pmap<string, vector_int> MultiThingsByName;
|
||||
|
Loading…
x
Reference in New Issue
Block a user