mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-11 02:25:34 -04:00
Cleanup RsThread and related classes
Removed antipattern abstraction RsSingleJobThread Rename runloop() method to run() in RsThread Ported few classes ineriting from RsSingleJobThread to RsThread RsThread use std::atomic instead of self implemented strange binary semaphores Removed RsTickingThread::shutdown() use RsThread::askForStop() instead Removed RsTickingThread::fullstop() use RsThread::fullstop() instead Stop properly JSON API server in retroshare-gui Centralize errno traslation to literal in util/rserrno.*
This commit is contained in:
parent
358aa1e0ab
commit
df87fe53b1
43 changed files with 490 additions and 587 deletions
|
@ -51,18 +51,13 @@ bool LocalDirectoryUpdater::isEnabled() const
|
|||
}
|
||||
void LocalDirectoryUpdater::setEnabled(bool b)
|
||||
{
|
||||
if(mIsEnabled == b)
|
||||
return ;
|
||||
|
||||
if(!b)
|
||||
shutdown();
|
||||
else if(!isRunning())
|
||||
start("fs dir updater") ;
|
||||
|
||||
mIsEnabled = b ;
|
||||
if(mIsEnabled == b) return;
|
||||
if(!b) RsThread::askForStop();
|
||||
else if(!RsThread::isRunning()) start("fs dir updater");
|
||||
mIsEnabled = b ;
|
||||
}
|
||||
|
||||
void LocalDirectoryUpdater::data_tick()
|
||||
void LocalDirectoryUpdater::threadTick()
|
||||
{
|
||||
rstime_t now = time(NULL) ;
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
bool ignoreDuplicates() const;
|
||||
|
||||
protected:
|
||||
virtual void data_tick() ;
|
||||
void threadTick() override; /// @see RsTickingThread
|
||||
|
||||
virtual void hash_callback(uint32_t client_param, const std::string& name, const RsFileHash& hash, uint64_t size);
|
||||
virtual bool hash_confirm(uint32_t client_param) ;
|
||||
|
|
|
@ -87,7 +87,7 @@ static std::string friendlyUnit(uint64_t val)
|
|||
return std::string(buf) + " TB";
|
||||
}
|
||||
|
||||
void HashStorage::data_tick()
|
||||
void HashStorage::threadTick()
|
||||
{
|
||||
FileHashJob job;
|
||||
RsFileHash hash;
|
||||
|
@ -318,14 +318,15 @@ void HashStorage::startHashThread()
|
|||
|
||||
void HashStorage::stopHashThread()
|
||||
{
|
||||
if (mRunning)
|
||||
{
|
||||
std::cerr << "Stopping hashing thread." << std::endl;
|
||||
shutdown();
|
||||
if(mRunning)
|
||||
{
|
||||
RsInfo() << __PRETTY_FUNCTION__ << "Stopping hashing thread."
|
||||
<< std::endl;
|
||||
|
||||
RsThread::askForStop();
|
||||
mRunning = false ;
|
||||
mTotalSizeToHash = 0;
|
||||
mTotalFilesToHash = 0;
|
||||
std::cerr << "done." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,9 +85,7 @@ public:
|
|||
void togglePauseHashingProcess() ;
|
||||
bool hashingProcessPaused();
|
||||
|
||||
// Functions called by the thread
|
||||
|
||||
virtual void data_tick() ;
|
||||
void threadTick() override; /// @see RsTickingThread
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& o,const HashStorageInfo& info) ;
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue