Mutex debugging: added a new macro RS_STACK_MUTEX(myMutex) to trigger a scope guard while recording file location and line number. Moved the timings from RsMutex to RsStackMutex. Changed the mutexes in rsgenexchange and rsgxsntservice to use the new macro.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7672 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-11-11 19:47:05 +00:00
parent b25f6f30ef
commit db4b87cd01
4 changed files with 128 additions and 73 deletions

View File

@ -221,7 +221,7 @@ void RsGenExchange::tick()
if (!grpIds.empty())
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED, false);
gc->mGrpIdList = grpIds;
@ -229,7 +229,7 @@ void RsGenExchange::tick()
}
if (!msgIds.empty()) {
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
c->msgChangeMap = msgIds;
@ -262,7 +262,7 @@ bool RsGenExchange::messagePublicationTest(const RsGxsMsgMetaData& meta)
bool RsGenExchange::acknowledgeTokenMsg(const uint32_t& token,
RsGxsGrpMsgIdPair& msgId)
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
#ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::acknowledgeTokenMsg(). token=" << token << std::endl;
@ -294,7 +294,7 @@ bool RsGenExchange::acknowledgeTokenMsg(const uint32_t& token,
bool RsGenExchange::acknowledgeTokenGrp(const uint32_t& token, RsGxsGroupId& grpId)
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
#ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::acknowledgeTokenGrp(). token=" << token << std::endl;
@ -984,7 +984,7 @@ bool RsGenExchange::checkAuthenFlag(const PrivacyBitPos& pos, const uint8_t& fla
void RsGenExchange::receiveChanges(std::vector<RsGxsNotify*>& changes)
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
#ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::receiveChanges()" << std::endl;
@ -1277,7 +1277,7 @@ bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem
bool RsGenExchange::getMsgData(const uint32_t &token, GxsMsgDataMap &msgItems)
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
NxsMsgDataResult msgResult;
bool ok = mDataAccess->getMsgData(token, msgResult);
NxsMsgDataResult::iterator mit = msgResult.begin();
@ -1328,7 +1328,7 @@ bool RsGenExchange::getMsgData(const uint32_t &token, GxsMsgDataMap &msgItems)
bool RsGenExchange::getMsgRelatedData(const uint32_t &token, GxsMsgRelatedDataMap &msgItems)
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
NxsMsgRelatedDataResult msgResult;
bool ok = mDataAccess->getMsgRelatedData(token, msgResult);
@ -1422,7 +1422,7 @@ bool RsGenExchange::setAuthenPolicyFlag(const uint8_t &msgFlag, uint32_t& authen
void RsGenExchange::notifyNewGroups(std::vector<RsNxsGrp *> &groups)
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
std::vector<RsNxsGrp*>::iterator vit = groups.begin();
@ -1456,7 +1456,7 @@ void RsGenExchange::notifyNewGroups(std::vector<RsNxsGrp *> &groups)
void RsGenExchange::notifyNewMessages(std::vector<RsNxsMsg *>& messages)
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
std::vector<RsNxsMsg*>::iterator vit = messages.begin();
@ -1492,7 +1492,7 @@ void RsGenExchange::notifyNewMessages(std::vector<RsNxsMsg *>& messages)
void RsGenExchange::publishGroup(uint32_t& token, RsGxsGrpItem *grpItem)
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
token = mDataAccess->generatePublicToken();
GxsGrpPendingSign ggps(grpItem, token);
mGrpsToPublish.push_back(ggps);
@ -1507,7 +1507,7 @@ void RsGenExchange::publishGroup(uint32_t& token, RsGxsGrpItem *grpItem)
void RsGenExchange::updateGroup(uint32_t& token, RsGxsGrpItem* grpItem)
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
token = mDataAccess->generatePublicToken();
mGroupUpdatePublish.push_back(GroupUpdatePublish(grpItem, token));
@ -1519,7 +1519,7 @@ void RsGenExchange::updateGroup(uint32_t& token, RsGxsGrpItem* grpItem)
void RsGenExchange::deleteGroup(uint32_t& token, RsGxsGrpItem* grpItem)
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
token = mDataAccess->generatePublicToken();
mGroupDeletePublish.push_back(GroupDeletePublish(grpItem, token));
@ -1531,7 +1531,7 @@ void RsGenExchange::deleteGroup(uint32_t& token, RsGxsGrpItem* grpItem)
void RsGenExchange::publishMsg(uint32_t& token, RsGxsMsgItem *msgItem)
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
token = mDataAccess->generatePublicToken();
mMsgsToPublish.insert(std::make_pair(token, msgItem));
@ -1545,7 +1545,7 @@ void RsGenExchange::publishMsg(uint32_t& token, RsGxsMsgItem *msgItem)
void RsGenExchange::setGroupSubscribeFlags(uint32_t& token, const RsGxsGroupId& grpId, const uint32_t& flag, const uint32_t& mask)
{
/* TODO APPLY MASK TO FLAGS */
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
token = mDataAccess->generatePublicToken();
GrpLocMetaData g;
@ -1558,7 +1558,7 @@ void RsGenExchange::setGroupSubscribeFlags(uint32_t& token, const RsGxsGroupId&
void RsGenExchange::setGroupStatusFlags(uint32_t& token, const RsGxsGroupId& grpId, const uint32_t& status, const uint32_t& mask)
{
/* TODO APPLY MASK TO FLAGS */
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
token = mDataAccess->generatePublicToken();
GrpLocMetaData g;
@ -1571,7 +1571,7 @@ void RsGenExchange::setGroupStatusFlags(uint32_t& token, const RsGxsGroupId& grp
void RsGenExchange::setGroupServiceString(uint32_t& token, const RsGxsGroupId& grpId, const std::string& servString)
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
token = mDataAccess->generatePublicToken();
GrpLocMetaData g;
@ -1583,7 +1583,7 @@ void RsGenExchange::setGroupServiceString(uint32_t& token, const RsGxsGroupId& g
void RsGenExchange::setMsgStatusFlags(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, const uint32_t& status, const uint32_t& mask)
{
/* TODO APPLY MASK TO FLAGS */
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
token = mDataAccess->generatePublicToken();
MsgLocMetaData m;
@ -1595,7 +1595,7 @@ void RsGenExchange::setMsgStatusFlags(uint32_t& token, const RsGxsGrpMsgIdPair&
void RsGenExchange::setMsgServiceString(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, const std::string& servString )
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
token = mDataAccess->generatePublicToken();
MsgLocMetaData m;
@ -1606,7 +1606,7 @@ void RsGenExchange::setMsgServiceString(uint32_t& token, const RsGxsGrpMsgIdPair
void RsGenExchange::processMsgMetaChanges()
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
GxsMsgReq msgIds;
@ -1682,7 +1682,7 @@ void RsGenExchange::processMsgMetaChanges()
void RsGenExchange::processGrpMetaChanges()
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
std::list<RsGxsGroupId> grpChanged;
@ -1775,7 +1775,7 @@ bool RsGenExchange::processGrpMask(const RsGxsGroupId& grpId, ContentValue &grpC
void RsGenExchange::publishMsgs()
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
// stick back msgs pending signature
typedef std::map<uint32_t, GxsPendingItem<RsGxsMsgItem*, uint32_t> > PendSignMap;
@ -1970,7 +1970,7 @@ RsGenExchange::ServiceCreate_Return RsGenExchange::service_CreateGroup(RsGxsGrpI
void RsGenExchange::processGroupUpdatePublish()
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
// get keys for group update publish
@ -2040,7 +2040,7 @@ void RsGenExchange::processGroupUpdatePublish()
void RsGenExchange::processRoutingClues()
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
for(std::map<RsGxsId,std::set<RsPeerId> >::const_iterator it = mRoutingClues.begin();it!=mRoutingClues.end();++it)
for(std::set<RsPeerId>::const_iterator it2(it->second.begin());it2!=it->second.end();++it2)
@ -2050,7 +2050,7 @@ void RsGenExchange::processRoutingClues()
}
void RsGenExchange::processGroupDelete()
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
// get keys for group delete publish
typedef std::pair<bool, RsGxsGroupId> GrpNote;
@ -2122,7 +2122,7 @@ bool RsGenExchange::checkKeys(const RsTlvSecurityKeySet& keySet)
void RsGenExchange::publishGrps()
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
NxsGrpSignPendVect::iterator vit = mGrpsToPublish.begin();
typedef std::pair<bool, RsGxsGroupId> GrpNote;
@ -2360,7 +2360,7 @@ bool RsGenExchange::getGroupKeys(const RsGxsGroupId &grpId, RsTlvSecurityKeySet
if(grpId.isNull())
return false;
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMeta;
grpMeta[grpId] = NULL;
@ -2410,7 +2410,7 @@ void RsGenExchange::computeHash(const RsTlvBinaryData& data, RsFileHash& hash)
void RsGenExchange::processRecvdMessages()
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
#ifdef GEN_EXCH_DEBUG
if(!mMsgPendingValidate.empty())
@ -2604,7 +2604,7 @@ void RsGenExchange::processRecvdMessages()
void RsGenExchange::processRecvdGroups()
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
if(mReceivedGrps.empty())
return;
@ -2721,7 +2721,7 @@ void RsGenExchange::processRecvdGroups()
void RsGenExchange::performUpdateValidation()
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
if(mGroupUpdates.empty())
return;
@ -2816,7 +2816,7 @@ bool RsGenExchange::updateValid(RsGxsGrpMetaData& oldGrpMeta, RsNxsGrp& newGrp)
void RsGenExchange::setGroupReputationCutOff(uint32_t& token, const RsGxsGroupId& grpId, int CutOff)
{
RsStackMutex stack(mGenMtx);
RS_STACK_MUTEX(mGenMtx) ;
token = mDataAccess->generatePublicToken();
GrpLocMetaData g;

View File

@ -106,7 +106,7 @@ public:
static void recordEvent(uint16_t service_type, RsItem *item)
{
RsStackMutex m(mtx) ;
RS_STACK_MUTEX(mtx) ;
uint32_t bw = RsNxsSerialiser(service_type).size(item) ; // this is used to estimate bandwidth.
timeval tv ;
@ -208,7 +208,7 @@ void RsGxsNetService::syncWithPeers()
static RsNxsSerialiser ser(mServType) ; // this is used to estimate bandwidth.
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
std::set<RsPeerId> peers;
mNetMgr->getOnlineList(mServiceInfo.mServiceType, peers);
@ -811,7 +811,7 @@ struct get_second : public std::unary_function<typename UpdateMap::value_type, R
bool RsGxsNetService::saveList(bool& cleanup, std::list<RsItem*>& save)
{
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
// hardcore templates
std::transform(mClientGrpUpdateMap.begin(), mClientGrpUpdateMap.end(),
@ -896,7 +896,7 @@ bool RsGxsNetService::handleTransaction(RsNxsItem* item)
* If it does then check this not a initiating transactions
*/
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
const RsPeerId& peer = item->PeerId();
@ -1081,7 +1081,7 @@ void RsGxsNetService::run(){
void RsGxsNetService::updateServerSyncTS()
{
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
std::map<RsGxsGroupId, RsGxsGrpMetaData*> gxsMap;
@ -1143,7 +1143,7 @@ bool RsGxsNetService::locked_checkTransacTimedOut(NxsTransaction* tr)
void RsGxsNetService::processTransactions(){
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
TransactionsPeerMap::iterator mit = mTransactions.begin();
@ -1330,7 +1330,7 @@ void RsGxsNetService::processTransactions(){
int RsGxsNetService::getGroupPopularity(const RsGxsGroupId& gid)
{
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
std::map<RsGxsGroupId,std::set<RsPeerId> >::const_iterator it = mGroupSuppliers.find(gid) ;
@ -1342,7 +1342,7 @@ int RsGxsNetService::getGroupPopularity(const RsGxsGroupId& gid)
void RsGxsNetService::processCompletedTransactions()
{
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
/*!
* Depending on transaction we may have to respond to peer
* responsible for transaction
@ -2006,7 +2006,7 @@ void RsGxsNetService::locked_genSendGrpsTransaction(NxsTransaction* tr)
void RsGxsNetService::runVetting()
{
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
std::vector<AuthorPending*>::iterator vit = mPendingResp.begin();
@ -2281,7 +2281,7 @@ bool RsGxsNetService::locked_CanReceiveUpdate(const RsNxsSyncGrp *item)
void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
{
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
if(!locked_CanReceiveUpdate(item))
{
@ -2629,7 +2629,7 @@ bool RsGxsNetService::locked_CanReceiveUpdate(const RsNxsSyncMsg *item)
}
void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsg* item)
{
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
// We do that early, so as to get info about who sends data about which group,
// even when the group doesn't need update.
@ -2827,14 +2827,14 @@ void RsGxsNetService::setSyncAge(uint32_t /* age */)
int RsGxsNetService::requestGrp(const std::list<RsGxsGroupId>& grpId, const RsPeerId& peerId)
{
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
mExplicitRequest[peerId].assign(grpId.begin(), grpId.end());
return 1;
}
void RsGxsNetService::processExplicitGroupRequests()
{
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
std::map<RsPeerId, std::list<RsGxsGroupId> >::const_iterator cit = mExplicitRequest.begin();
@ -2866,7 +2866,7 @@ void RsGxsNetService::processExplicitGroupRequests()
#define NXS_NET_DEBUG
int RsGxsNetService::sharePublishKey(const RsGxsGroupId& grpId,const std::list<RsPeerId>& peers)
{
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
mPendingPublishKeyRecipients[grpId] = peers ;
@ -2877,7 +2877,7 @@ int RsGxsNetService::sharePublishKey(const RsGxsGroupId& grpId,const std::list<R
void RsGxsNetService::sharePublishKeysPending()
{
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
if(mPendingPublishKeyRecipients.empty())
return ;
@ -3001,7 +3001,7 @@ void RsGxsNetService::handleRecvPublishKeys(RsNxsGroupPublishKeyItem *item)
#ifdef NXS_NET_DEBUG
std::cerr << "RsGxsNetService::sharePublishKeys() " << std::endl;
#endif
RsStackMutex stack(mNxsMutex);
RS_STACK_MUTEX(mNxsMutex) ;
#ifdef NXS_NET_DEBUG
std::cerr << " PeerId : " << item->PeerId() << std::endl;

View File

@ -185,12 +185,6 @@ void RsMutex::unlock()
#endif
#ifndef WIN32
_thread_id = 0 ;
#endif
#ifdef RSMUTEX_DEBUG
double ts = getCurrentTS() ;
if(ts - _time_stamp > 1.0) // locked for more than 0.5 seconds => somthing fishy is happenning
std::cerr << "Mutex " << (void*)this << " \"" << name << "\"" << " got locked for " << ts - _time_stamp << " seconds in thread " << pthread_self() << std::endl;
#endif
pthread_mutex_unlock(&realMutex);
@ -202,7 +196,6 @@ void RsMutex::unlock()
void RsMutex::lock()
{
#ifdef RSMUTEX_DEBUG
_time_stamp = getCurrentTS() ;
pthread_t owner = _thread_id ;
#endif
@ -213,14 +206,6 @@ void RsMutex::lock()
#endif
retval = pthread_mutex_lock(&realMutex);
#ifdef RSMUTEX_DEBUG
double ts = getCurrentTS() ;
if(ts - _time_stamp > 1.0)
std::cerr << "Mutex " << (void*)this << " \"" << name << "\"" << " waited for " << ts - _time_stamp << " seconds in thread " << pthread_self() << " for locked thread " << owner << std::endl;
_time_stamp = getCurrentTS() ; // This is to re-init the locking time without accounting for how much we waited.
#endif
switch(retval)
{
case 0:
@ -279,9 +264,8 @@ void RsMutex::lock()
++_cnt ;
#endif
}
#ifdef RSMUTEX_DEBUG
double RsMutex::getCurrentTS()
double RsStackMutex::getCurrentTS()
{
#ifndef WINDOWS_SYS
@ -297,3 +281,4 @@ double RsMutex::getCurrentTS()
}
#endif

View File

@ -30,6 +30,7 @@
#include <pthread.h>
#include <inttypes.h>
#include <string>
#include <iostream>
/* RsIface Thread Wrappers */
@ -44,14 +45,15 @@ class RsMutex
RsMutex(const std::string& name)
{
/* remove unused parameter warnings */
(void) name;
pthread_mutex_init(&realMutex, NULL);
#ifdef RSTHREAD_SELF_LOCKING_GUARD
_thread_id = 0 ;
#endif
#ifdef RSMUTEX_DEBUG
this->name = name;
this->_name = name;
#else
(void) name;
#endif
}
~RsMutex()
@ -63,7 +65,7 @@ class RsMutex
#ifdef RSMUTEX_DEBUG
void setName(const std::string &name)
{
this->name = name;
this->_name = name;
}
#endif
@ -71,6 +73,10 @@ class RsMutex
void unlock();
bool trylock() { return (0 == pthread_mutex_trylock(&realMutex)); }
#ifdef RSMUTEX_DEBUG
const std::string& name() const { return _name ; }
#endif
private:
pthread_mutex_t realMutex;
pthread_t _thread_id ;
@ -78,10 +84,7 @@ class RsMutex
uint32_t _cnt ;
#endif
#ifdef RSMUTEX_DEBUG
static double getCurrentTS() ;
std::string name;
double _time_stamp ;
std::string _name;
#endif
};
@ -89,13 +92,80 @@ class RsStackMutex
{
public:
RsStackMutex(RsMutex &mtx): mMtx(mtx) { mMtx.lock(); }
~RsStackMutex() { mMtx.unlock(); }
RsStackMutex(RsMutex &mtx)
: mMtx(mtx)
{
mMtx.lock();
#ifdef RSMUTEX_DEBUG
double ts = getCurrentTS() ;
_time_stamp = ts ;
_lineno = 0 ;
_info = "[no info]" ;
#endif
}
RsStackMutex(RsMutex &mtx,const char *function_name,const char *file_name,int lineno)
: mMtx(mtx)
#ifdef RSMUTEX_DEBUG
, _info(std::string(function_name)+" in file "+file_name),_lineno(lineno)
#endif
{
#ifdef RSMUTEX_DEBUG
double ts = getCurrentTS() ;
_time_stamp = ts ;
pthread_t owner = mMtx.owner() ;
#endif
mMtx.lock();
#ifdef RSMUTEX_DEBUG
ts = getCurrentTS() ;
if(ts - _time_stamp > 1.0)
std::cerr << "Mutex " << (void*)&mMtx << " \"" << mtx.name() << "\""
<< " waited for " << ts - _time_stamp
<< " seconds in thread " << pthread_self()
<< " for locked thread " << owner << ". in " << _info << ":" << _lineno << std::endl;
_time_stamp = ts ; // This is to re-init the locking time without accounting for how much we waited.
#endif
}
~RsStackMutex()
{
mMtx.unlock();
#ifdef RSMUTEX_DEBUG
double ts = getCurrentTS() ;
if(ts - _time_stamp > 1.0)
std::cerr << "Mutex " << (void*)&mMtx << " \"" << mMtx.name() << "\""
<< " locked for " << ts - _time_stamp
<< " seconds in thread " << pthread_self()
<< ". in " << _info << ":" << _lineno << std::endl;
#endif
}
private:
RsMutex &mMtx;
#ifdef RSMUTEX_DEBUG
static double getCurrentTS() ;
double _time_stamp ;
std::string _info ;
int _lineno ;
#endif
};
// This macro allows you to trace which mutex in the code is locked for how much time.
// se this as follows:
//
// {
// RS_STACK_MUTEX(myMutex) ;
//
// do_something() ;
// }
//
#define RS_STACK_MUTEX(m) RsStackMutex __local_retroshare_mutex(m,__PRETTY_FUNCTION__,__FILE__,__LINE__)
class RsThread;
/* to create a thread! */