mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
created 2 subclasses of RsThread, one for ticking services, and one for single shot jobs. Now all threads use the same base code.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8288 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f2d4a237ca
commit
e9b9dce9f5
28 changed files with 317 additions and 335 deletions
|
@ -146,16 +146,13 @@ RsGenExchange::~RsGenExchange()
|
|||
|
||||
}
|
||||
|
||||
void RsGenExchange::run()
|
||||
void RsGenExchange::data_tick()
|
||||
{
|
||||
|
||||
double timeDelta = 0.1; // slow tick in sec
|
||||
static const double timeDelta = 0.1; // slow tick in sec
|
||||
|
||||
while(isRunning()) {
|
||||
tick();
|
||||
|
||||
usleep((int) (timeDelta * 1000 *1000)); // timeDelta sec
|
||||
}//while(isRunning())
|
||||
usleep((int) (timeDelta * 1000 *1000)); // timeDelta sec
|
||||
}
|
||||
|
||||
void RsGenExchange::tick()
|
||||
|
@ -238,7 +235,6 @@ void RsGenExchange::tick()
|
|||
mNotifications.push_back(c);
|
||||
}
|
||||
|
||||
mIntegrityCheck->join();
|
||||
delete mIntegrityCheck;
|
||||
mIntegrityCheck = NULL;
|
||||
mLastCheck = time(NULL);
|
||||
|
|
|
@ -109,7 +109,7 @@ typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMsgItem*> > GxsMsgRelatedDa
|
|||
|
||||
class RsGixs;
|
||||
|
||||
class RsGenExchange : public RsNxsObserver, public RsThread, public RsGxsIface
|
||||
class RsGenExchange : public RsNxsObserver, public RsTickingThread, public RsGxsIface
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -182,7 +182,7 @@ public:
|
|||
*/
|
||||
RsTokenService* getTokenService();
|
||||
|
||||
void run();
|
||||
virtual void data_tick();
|
||||
|
||||
/*!
|
||||
* Policy bit pattern portion
|
||||
|
|
|
@ -73,6 +73,7 @@ RsGxsNetService::RsGxsNetService(uint16_t servType, RsGeneralDataService *gds,
|
|||
{
|
||||
addSerialType(new RsNxsSerialiser(mServType));
|
||||
mOwnId = mNetMgr->getOwnId();
|
||||
mUpdateCounter = 0;
|
||||
}
|
||||
|
||||
RsGxsNetService::~RsGxsNetService()
|
||||
|
@ -1149,23 +1150,20 @@ bool RsGxsNetService::locked_processTransac(RsNxsTransac* item)
|
|||
return false;
|
||||
}
|
||||
|
||||
void RsGxsNetService::run()
|
||||
void RsGxsNetService::data_tick()
|
||||
{
|
||||
double timeDelta = 0.5;
|
||||
int updateCounter = 0;
|
||||
static const double timeDelta = 0.5;
|
||||
|
||||
while(isRunning())
|
||||
{
|
||||
//Start waiting as nothing to do in runup
|
||||
usleep((int) (timeDelta * 1000 * 1000)); // timeDelta sec
|
||||
|
||||
if(updateCounter >= 20)
|
||||
if(mUpdateCounter >= 20)
|
||||
{
|
||||
updateServerSyncTS();
|
||||
updateCounter = 0;
|
||||
mUpdateCounter = 0;
|
||||
}
|
||||
else
|
||||
updateCounter++;
|
||||
mUpdateCounter++;
|
||||
|
||||
// process active transactions
|
||||
processTransactions();
|
||||
|
@ -1177,8 +1175,6 @@ void RsGxsNetService::run()
|
|||
runVetting();
|
||||
|
||||
processExplicitGroupRequests();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void RsGxsNetService::updateServerSyncTS()
|
||||
|
|
|
@ -168,7 +168,7 @@ public:
|
|||
/*!
|
||||
* Processes transactions and job queue
|
||||
*/
|
||||
void run();
|
||||
virtual void data_tick();
|
||||
private:
|
||||
|
||||
/*!
|
||||
|
@ -477,6 +477,7 @@ private:
|
|||
uint32_t mLastKeyPublishTs;
|
||||
|
||||
const uint32_t mSYNC_PERIOD;
|
||||
int mUpdateCounter ;
|
||||
|
||||
RsGcxs* mCircles;
|
||||
RsGixsReputation* mReputations;
|
||||
|
|
|
@ -61,7 +61,7 @@ inline RsGxsGrpMsgIdPair getMsgIdPair(RsGxsMsgItem& msg)
|
|||
* Does message clean up based on individual group expirations first
|
||||
* if avialable. If not then deletion s
|
||||
*/
|
||||
class RsGxsMessageCleanUp : public RsThread
|
||||
class RsGxsMessageCleanUp //: public RsThread
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
/*!
|
||||
* TODO: Rather than manual progressions consider running through a thread
|
||||
*/
|
||||
void run(){}
|
||||
//virtual void data_tick(){}
|
||||
|
||||
private:
|
||||
|
||||
|
@ -97,7 +97,7 @@ private:
|
|||
* Checks the integrity message and groups
|
||||
* in rsDataService using computed hash
|
||||
*/
|
||||
class RsGxsIntegrityCheck : public RsThread
|
||||
class RsGxsIntegrityCheck : public RsSingleJobThread
|
||||
{
|
||||
|
||||
enum CheckState { CheckStart, CheckChecking };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue