From 6fde6b0fe90abde84011202edd40fe46eb06af44 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 21 Nov 2010 16:20:55 +0000 Subject: --- src/monitor/dump.cpp | 5 ++--- src/monitor/dump.h | 13 ++++++------- src/monitor/stats.cpp | 22 +++++++++++++++++++--- src/monitor/stats.h | 5 +++-- 4 files changed, 30 insertions(+), 15 deletions(-) (limited to 'src/monitor') diff --git a/src/monitor/dump.cpp b/src/monitor/dump.cpp index e249767..da220f4 100644 --- a/src/monitor/dump.cpp +++ b/src/monitor/dump.cpp @@ -1,12 +1,11 @@ /*:* *: File: ./src/monitor/dump.cpp *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT + *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT *: *: Copyright (C) 2003 Paul C. Buetow, Volker Richter *: Copyright (C) 2004 Paul C. Buetow *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow *: *: This program is free software; you can redistribute it and/or *: modify it under the terms of the GNU General Public License @@ -64,7 +63,7 @@ dumpable::dump(int i_level) void dumpable::add -(string s_line) + (string s_line) { if ( i_lined > i_max_level ) i_lined = i_max_level; diff --git a/src/monitor/dump.h b/src/monitor/dump.h index 7f4b59b..e1915e7 100644 --- a/src/monitor/dump.h +++ b/src/monitor/dump.h @@ -1,12 +1,11 @@ /*:* *: File: ./src/monitor/dump.h *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT + *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT *: *: Copyright (C) 2003 Paul C. Buetow, Volker Richter *: Copyright (C) 2004 Paul C. Buetow *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow *: *: This program is free software; you can redistribute it and/or *: modify it under the terms of the GNU General Public License @@ -48,21 +47,21 @@ private: protected: void add - (unsigned i_num) + (unsigned i_num) { add - (""); + (""); } void add - (int i_num) + (int i_num) { add - (""); + (""); } void add - (string s_line); + (string s_line); dumpable(); void next_no_newline() diff --git a/src/monitor/stats.cpp b/src/monitor/stats.cpp index cd69673..c8539ad 100644 --- a/src/monitor/stats.cpp +++ b/src/monitor/stats.cpp @@ -1,12 +1,11 @@ /*:* *: File: ./src/monitor/stats.cpp *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT + *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT *: *: Copyright (C) 2003 Paul C. Buetow, Volker Richter *: Copyright (C) 2004 Paul C. Buetow *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow *: *: This program is free software; you can redistribute it and/or *: modify it under the terms of the GNU General Public License @@ -37,11 +36,16 @@ stats::stats() i_num_rooms = 0; //<< + pthread_mutex_init( &mut_vec_rusage, NULL ); + pthread_mutex_init( &mut_num_rooms, NULL ); //<< } stats::~stats() -{} +{ + pthread_mutex_destroy( &mut_vec_rusage ); + pthread_mutex_destroy( &mut_num_rooms ); //<< +} void stats::update_rusage_history() @@ -70,18 +74,22 @@ stats::update_rusage_history() delete p_rusage; + pthread_mutex_lock ( &mut_vec_rusage ); if ( vec_rusage_history.size() >= i_rusage_vec_size ) vec_rusage_history.erase( vec_rusage_history.begin() ); vec_rusage_history.push_back(map_rusage); + pthread_mutex_unlock( &mut_vec_rusage ); } void stats::set_rusage_vec_size( int i_rusage_vec_size ) { + pthread_mutex_lock ( &mut_vec_rusage ); this->i_rusage_vec_size = i_rusage_vec_size; + pthread_mutex_unlock( &mut_vec_rusage ); } long @@ -103,6 +111,7 @@ stats::get_rusage_history( string s_type, string s_seperator ) int i_count = 0; vector< map >::iterator iter; + pthread_mutex_lock ( &mut_vec_rusage ); for ( iter = vec_rusage_history.begin(); iter != vec_rusage_history.end(); @@ -111,6 +120,7 @@ stats::get_rusage_history( string s_type, string s_seperator ) tool::int2string(i_count) + ". " + iter->find(s_type)->first + " " + tool::int2string( iter->find(s_type)->second) + "\n"); + pthread_mutex_unlock( &mut_vec_rusage ); return s_ret; } @@ -119,19 +129,25 @@ stats::get_rusage_history( string s_type, string s_seperator ) int stats::get_num_rooms() { + pthread_mutex_lock ( &mut_num_rooms ); int i_ret = i_num_rooms; + pthread_mutex_unlock( &mut_num_rooms ); return i_ret; } void stats::increment_num_rooms() { + pthread_mutex_lock ( &mut_num_rooms ); ++i_num_rooms; + pthread_mutex_unlock( &mut_num_rooms ); } void stats::decrement_num_rooms() { + pthread_mutex_lock ( &mut_num_rooms ); --i_num_rooms; + pthread_mutex_unlock( &mut_num_rooms ); } //*>> diff --git a/src/monitor/stats.h b/src/monitor/stats.h index 4b8aa13..b4dd10a 100644 --- a/src/monitor/stats.h +++ b/src/monitor/stats.h @@ -1,12 +1,11 @@ /*:* *: File: ./src/monitor/stats.h *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT + *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT *: *: Copyright (C) 2003 Paul C. Buetow, Volker Richter *: Copyright (C) 2004 Paul C. Buetow *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow *: *: This program is free software; you can redistribute it and/or *: modify it under the terms of the GNU General Public License @@ -44,8 +43,10 @@ private: int i_rusage_vec_size; // History of the last i_rusage_vec_size rusage values. vector< map > vec_rusage_history; + pthread_mutex_t mut_vec_rusage; int i_num_rooms; //<< + pthread_mutex_t mut_num_rooms; //<< void set_rusage_vec_size( int i_rusage_vec_size ); -- cgit v1.2.3