crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
crawlservpp::Module::Thread Class Referenceabstract

Abstract class providing module-independent thread functionality. More...

#include <Thread.hpp>

Inheritance diagram for crawlservpp::Module::Thread:
Collaboration diagram for crawlservpp::Module::Thread:

Classes

class  Exception
 Class for generic thread exceptions. More...
 

Construction and Destruction

 Thread (Main::Database &dbBase, const ThreadOptions &threadOptions, const ThreadStatus &threadStatus)
 Constructor initializing a previously interrupted thread. More...
 
 Thread (Main::Database &dbBase, const ThreadOptions &threadOptions)
 Constructor initializing a new thread. More...
 
virtual ~Thread ()=default
 Default destructor. More...
 

Getters

std::uint64_t getId () const
 Gets the ID of the thread. More...
 
std::uint64_t getWebsite () const
 Gets the ID of the website used by the thread. More...
 
std::uint64_t getUrlList () const
 Gets the ID of the URL list used by the thread. More...
 
std::uint64_t getConfig () const
 Gets the ID of the configuration used by the thread. More...
 
bool isShutdown () const
 Checks whether the thread is shutting down or has shut down. More...
 
bool isRunning () const
 Checks whether the thread is still supposed to run. More...
 
bool isFinished () const
 Checks whether the shutdown of the thread has been finished. More...
 
bool isPaused () const
 Checks whether the thread has been paused. More...
 

Thread Control

void start ()
 Starts running the thread. More...
 
bool pause ()
 Pauses the thread. More...
 
void unpause ()
 Unpauses the thread. More...
 
void stop ()
 Shuts down the thread. More...
 
void interrupt ()
 Interrupts the thread due to an exception. More...
 
void end ()
 Waits for the thread until shutdown is completed. More...
 
void reset ()
 Will reset the thread before the next tick. More...
 

Time Travel

void warpTo (std::uint64_t target)
 Jumps to the specified target ID ("time travel"). More...
 

Copy and Move

The class is neither copyable, nor movable.

 Thread (Thread &)=delete
 Deleted copy constructor. More...
 
Threadoperator= (Thread &)=delete
 Deleted copy assignment operator. More...
 
 Thread (Thread &&)=delete
 Deleted move constructor. More...
 
Threadoperator= (Thread &&)=delete
 Deleted move assignment operator. More...
 

Database Connection

Database database
 Database connection for the thread. More...
 

Configuration

std::string websiteNamespace
 Namespace of the website used by the thread. More...
 
std::string urlListNamespace
 Namespace of the URL list used by the thread. More...
 
std::string configuration
 JSON string of the configuration used by the thread. More...
 

Protected Getters

bool isInterrupted () const
 Checks whether the thread has been interrupted. More...
 
std::string getStatusMessage () const
 Gets the current status message. More...
 
float getProgress () const
 Gets the current progress, in percent. More...
 
std::uint64_t getLast () const
 Gets the value of the last ID processed by the thread. More...
 
std::int64_t getWarpedOverAndReset ()
 Gets the number of IDs that have been jumped over, and resets them. More...
 

Protected Setters

void setStatusMessage (const std::string &statusMessage)
 Sets the status message of the thread. More...
 
void setProgress (float newProgress)
 Sets the progress of the thread. More...
 
void setLast (std::uint64_t lastId)
 Sets the last ID processed by the thread. More...
 
void incrementLast ()
 Increments the last ID processed by the thread. More...
 
void incrementProcessed ()
 Increments the number of IDs processed by the thread. More...
 

Protected Thread Control

void sleep (std::uint64_t ms) const
 Lets the thread sleep for the specified number of milliseconds. More...
 
void allowPausing ()
 Allows the thread to be paused. More...
 
void disallowPausing ()
 Disallows the thread to be paused. More...
 
void pauseByThread ()
 Forces the thread to pause. More...
 

Logging

bool isLogLevel (std::uint8_t level) const
 Checks whether a certain logging level is enabled. More...
 
void log (std::uint8_t level, const std::string &logEntry)
 Adds a thread-specific log entry to the database, if the current logging level is high enough. More...
 
void log (std::uint8_t level, std::queue< std::string > &logEntries)
 Adds multiple thread-specific log entries to the database, if the current logging level is high enough. More...
 

Events

virtual void onInit ()=0
 Initializes the module. More...
 
virtual void onTick ()=0
 Performs a module tick. More...
 
virtual void onPause ()=0
 Pauses the module. More...
 
virtual void onUnpause ()=0
 Unpauses the module. More...
 
virtual void onClear ()=0
 Clears the module. More...
 
virtual void onReset ()=0
 Resets the module. More...
 

Detailed Description

Abstract class providing module-independent thread functionality.

Constructor & Destructor Documentation

◆ Thread() [1/4]

crawlservpp::Module::Thread::Thread ( Main::Database dbBase,
const ThreadOptions threadOptions,
const ThreadStatus threadStatus 
)

◆ Thread() [2/4]

crawlservpp::Module::Thread::Thread ( Main::Database dbBase,
const ThreadOptions threadOptions 
)

Constructor initializing a new thread.

Parameters
dbBaseReference to the main database connection.
threadOptionsConstant reference to a structure containing the options for the thread.

References crawlservpp::Main::Database::addThread(), database, and crawlservpp::Module::Database::setThreadId().

◆ ~Thread()

virtual crawlservpp::Module::Thread::~Thread ( )
virtualdefault

Default destructor.

◆ Thread() [3/4]

crawlservpp::Module::Thread::Thread ( Thread )
delete

Deleted copy constructor.

◆ Thread() [4/4]

crawlservpp::Module::Thread::Thread ( Thread &&  )
delete

Deleted move constructor.

Member Function Documentation

◆ allowPausing()

void crawlservpp::Module::Thread::allowPausing ( )
protected

Allows the thread to be paused.

Threads are pausable by default. Use this function if pausing has been disallowed via disallowPausing().

Thread-safe: Can be used by both the module and the main thread.

◆ disallowPausing()

◆ end()

void crawlservpp::Module::Thread::end ( )

Waits for the thread until shutdown is completed.

Note
Either stop() or interrupt() must have been called before calling this function.
Warning
May not be used by the thread itself!

References crawlservpp::Main::Database::deleteThread().

Referenced by crawlservpp::Module::Crawler::Thread::onReset(), and crawlservpp::Module::Analyzer::Algo::SentimentOverTime::resetAlgo().

◆ getConfig()

std::uint64_t crawlservpp::Module::Thread::getConfig ( ) const

Gets the ID of the configuration used by the thread.

Thread-safe: Can be used by both the module and the main thread, because the configuration is not changed after starting the thread.

Returns
The unique ID identifying the used configuration in the database.

References crawlservpp::Struct::ThreadOptions::config.

Referenced by Thread().

◆ getId()

std::uint64_t crawlservpp::Module::Thread::getId ( ) const

Gets the ID of the thread.

Thread-safe: Can be used by both the module and the main thread.

Returns
The unique ID identifying the thread in the database, because the ID is not changed after starting the thread.

◆ getLast()

std::uint64_t crawlservpp::Module::Thread::getLast ( ) const
protected

Gets the value of the last ID processed by the thread.

Warning
May only be used by the thread itself, not by the main thread!
Returns
The ID last processed by the thread, or zero if no ID has been processed yet.

Referenced by crawlservpp::Module::Crawler::Thread::onInit(), crawlservpp::Module::Parser::Thread::onReset(), crawlservpp::Module::Extractor::Thread::onReset(), crawlservpp::Module::Crawler::Thread::onReset(), crawlservpp::Module::Parser::Thread::onTick(), and crawlservpp::Module::Extractor::Thread::onTick().

◆ getProgress()

float crawlservpp::Module::Thread::getProgress ( ) const
protected

Gets the current progress, in percent.

Thread-safe: Can be used by both the module and the main thread.

Returns
The current progress of the thread, in percent – between 0.F (none) and 1.F (done).

Referenced by crawlservpp::Module::Parser::Thread::onReset(), and crawlservpp::Module::Extractor::Thread::onReset().

◆ getStatusMessage()

std::string crawlservpp::Module::Thread::getStatusMessage ( ) const
protected

Gets the current status message.

Thread-safe: Can be used by both the module and the main thread.

Returns
A copy of the current status message.

Referenced by log(), crawlservpp::Module::Parser::Thread::onClear(), crawlservpp::Module::Extractor::Thread::onClear(), crawlservpp::Module::Parser::Thread::onReset(), crawlservpp::Module::Extractor::Thread::onReset(), and crawlservpp::Module::Crawler::Thread::onReset().

◆ getUrlList()

std::uint64_t crawlservpp::Module::Thread::getUrlList ( ) const

Gets the ID of the URL list used by the thread.

Thread-safe: Can be used by both the module and the main thread, because the URL list is not changed after starting the thread.

Returns
The unique ID identifying the used URL list in the database.

References crawlservpp::Struct::ThreadOptions::urlList.

Referenced by Thread().

◆ getWarpedOverAndReset()

std::int64_t crawlservpp::Module::Thread::getWarpedOverAndReset ( )
protected

Gets the number of IDs that have been jumped over, and resets them.

Resets the number of IDs jumped over to zero.

Warning
May only be used by the thread itself, not by the main thread!
Returns
The number of IDs that have been jumped over due to a call to warpTo(), or zero if no IDs have been jumped over, at least not since the last call to getWarpedOverAndReset(). The result might be negative, if warpTo() resulted in a jump to a previous ID.

Referenced by crawlservpp::Module::Crawler::Thread::onReset(), crawlservpp::Module::Parser::Thread::onTick(), and crawlservpp::Module::Extractor::Thread::onTick().

◆ getWebsite()

std::uint64_t crawlservpp::Module::Thread::getWebsite ( ) const

Gets the ID of the website used by the thread.

Thread-safe: Can be used by both the module and the main thread, because the website is not changed after starting the thread.

Returns
The unique ID identifying the used website in the database.

References crawlservpp::Struct::ThreadOptions::website.

Referenced by crawlservpp::Module::Crawler::Thread::onReset(), and Thread().

◆ incrementLast()

void crawlservpp::Module::Thread::incrementLast ( )
protected

Increments the last ID processed by the thread.

Also sets the number of processed IDs, make sure to increment it before if the ID has been processed.

Warning
May only be used by the thread itself, not by the main thread!
See also
incrementProcessed, setLast, Main::Database::setThreadLast

References database, and crawlservpp::Module::Database::setThreadLast().

◆ incrementProcessed()

void crawlservpp::Module::Thread::incrementProcessed ( )
protected

Increments the number of IDs processed by the thread.

Warning
May only be used by the thread itself, not by the main thread!
See also
setLast, incrementLast

Referenced by crawlservpp::Module::Parser::Thread::onReset(), crawlservpp::Module::Extractor::Thread::onReset(), and crawlservpp::Module::Crawler::Thread::onReset().

◆ interrupt()

void crawlservpp::Module::Thread::interrupt ( )

Interrupts the thread due to an exception.

Note
end() needs to be called afterwards to wait for the thread.
Warning
May not be used by the thread itself!

References unpause().

◆ isFinished()

bool crawlservpp::Module::Thread::isFinished ( ) const

Checks whether the shutdown of the thread has been finished.

Thread-safe: Can be used by both the module and the main thread.

Returns
True, if the thread has been completely shut down. False otherwise.

◆ isInterrupted()

bool crawlservpp::Module::Thread::isInterrupted ( ) const
protected

Checks whether the thread has been interrupted.

Thread-safe: Can be used by both the module and the main thread.

Returns
True if the thread has been interrupted. False otherwise.

◆ isLogLevel()

bool crawlservpp::Module::Thread::isLogLevel ( std::uint8_t  level) const
protected

Checks whether a certain logging level is enabled.

Warning
May only be used by the thread itself, not by the main thread!
Parameters
levelThe logging level to be checked for.
Returns
True, if the current logging level is at least as high as the given level. False, if the current logging level is lower than the given one.

References database, and crawlservpp::Module::Database::isLogLevel().

Referenced by crawlservpp::Module::Parser::Thread::onReset(), crawlservpp::Module::Extractor::Thread::onReset(), crawlservpp::Module::Crawler::Thread::onReset(), crawlservpp::Module::Parser::Thread::onTick(), and crawlservpp::Module::Extractor::Thread::onTick().

◆ isPaused()

bool crawlservpp::Module::Thread::isPaused ( ) const

Checks whether the thread has been paused.

Thread-safe: Can be used by both the module and the main thread.

Returns
True, if the thread has been paused. False otherwise.

◆ isRunning()

bool crawlservpp::Module::Thread::isRunning ( ) const

Checks whether the thread is still supposed to run.

Thread-safe: Can be used by both the module and the main thread.

Returns
True, if the thread is has not been cancelled, even when it is paused. False, if the thread is not supposed to run any longer.

Referenced by crawlservpp::Module::Analyzer::Thread::cleanUpQueries(), crawlservpp::Module::Analyzer::Algo::TermsOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::ExtractIds::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::CorpusGenerator::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::WordsOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::Assoc::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::AssocOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::AllTokens::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::Empty::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::SentimentOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::TopicModelling::onAlgoInit(), crawlservpp::Module::Analyzer::Thread::onInit(), crawlservpp::Module::Parser::Thread::onInit(), crawlservpp::Module::Extractor::Thread::onInit(), crawlservpp::Module::Crawler::Thread::onInit(), crawlservpp::Module::Parser::Thread::onReset(), crawlservpp::Module::Extractor::Thread::onReset(), crawlservpp::Module::Crawler::Thread::onReset(), crawlservpp::Module::Parser::Thread::onTick(), crawlservpp::Module::Analyzer::Algo::ExtractIds::resetAlgo(), crawlservpp::Module::Analyzer::Algo::WordsOverTime::resetAlgo(), crawlservpp::Module::Analyzer::Algo::Assoc::resetAlgo(), crawlservpp::Module::Analyzer::Algo::AssocOverTime::resetAlgo(), crawlservpp::Module::Analyzer::Algo::AllTokens::resetAlgo(), crawlservpp::Module::Analyzer::Algo::SentimentOverTime::resetAlgo(), and crawlservpp::Module::Analyzer::Algo::TopicModelling::resetAlgo().

◆ isShutdown()

bool crawlservpp::Module::Thread::isShutdown ( ) const

Checks whether the thread is shutting down or has shut down.

Thread-safe: Can be used by both the module and the main thread.

Returns
True, if the thread is shutting down or has been shut down. False, if the thread is continuing to run.
See also
Thread::isFinished

◆ log() [1/2]

void crawlservpp::Module::Thread::log ( std::uint8_t  level,
const std::string &  logEntry 
)
protected

Adds a thread-specific log entry to the database, if the current logging level is high enough.

Removes invalid UTF-8 characters if necessary.

If debug logging is active, the entry will be written to the logging file as well.

The log entry will not be written to the database, if the current logging level is lower than the specified logging level. The logging level does not affect the writing of logging entries being to the logging file when debug logging is active.

Warning
May only be used by the thread itself, not by the main thread!
Note
String views cannot be used, because they are not supported by the API for the MySQL database.
Parameters
levelThe logging level for the entry. The entry will only be written to the database, if the current logging level is at least the logging level for the entry.
logEntryConstant reference to a string containing the log entry.
See also
Module::Database::log(std::uint8_t, const std::string&)

References database, and crawlservpp::Module::Database::log().

Referenced by crawlservpp::Module::Analyzer::Thread::addCorpora(), crawlservpp::Module::Analyzer::Algo::TopicModelling::checkAlgoOptions(), crawlservpp::Module::Analyzer::Thread::cleanUpQueries(), crawlservpp::Module::Analyzer::Thread::finished(), log(), crawlservpp::Module::Analyzer::Algo::TermsOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::ExtractIds::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::CorpusGenerator::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::WordsOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::Assoc::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::AssocOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::AllTokens::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::Empty::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::SentimentOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::TopicModelling::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::AllTokens::onAlgoTick(), crawlservpp::Module::Parser::Thread::onClear(), crawlservpp::Module::Extractor::Thread::onClear(), crawlservpp::Module::Crawler::Thread::onClear(), crawlservpp::Module::Analyzer::Thread::onReset(), crawlservpp::Module::Parser::Thread::onReset(), crawlservpp::Module::Extractor::Thread::onReset(), crawlservpp::Module::Crawler::Thread::onReset(), crawlservpp::Module::Parser::Thread::onTick(), crawlservpp::Module::Extractor::Thread::onTick(), crawlservpp::Module::Analyzer::Algo::TermsOverTime::resetAlgo(), crawlservpp::Module::Analyzer::Algo::ExtractIds::resetAlgo(), crawlservpp::Module::Analyzer::Algo::WordsOverTime::resetAlgo(), crawlservpp::Module::Analyzer::Algo::Assoc::resetAlgo(), crawlservpp::Module::Analyzer::Algo::AssocOverTime::resetAlgo(), crawlservpp::Module::Analyzer::Algo::AllTokens::resetAlgo(), crawlservpp::Module::Analyzer::Algo::SentimentOverTime::resetAlgo(), crawlservpp::Module::Analyzer::Algo::TopicModelling::resetAlgo(), and crawlservpp::Module::Analyzer::Thread::uploadResult().

◆ log() [2/2]

void crawlservpp::Module::Thread::log ( std::uint8_t  level,
std::queue< std::string > &  logEntries 
)
protected

Adds multiple thread-specific log entries to the database, if the current logging level is high enough.

Removes invalid UTF-8 characters if necessary.

If debug logging is active, the entries will be written to the logging file as well.

The log entries will not be written to the database, if the current logging level is lower than the specified logging level. The logging level does not affect the writing of logging entries being to the logging file when debug logging is active.

Warning
May only be used by the thread itself, not by the main thread!
Note
String views cannot be used, because they are not supported by the API for the MySQL database.
Parameters
levelThe logging level for the entries. The entries will only be written to the database, if the current logging level is at least the logging level for the entry.
logEntriesReference to a queue of strings containing the log entries to be written. It will be emptied regardless whether the log entries will be written to the database.
See also
Module::Database::log(std::uint8_t, std::queue<std::string>&)

References crawlservpp::Main::Database::connect(), database, getStatusMessage(), crawlservpp::Main::Database::getThreadPauseTime(), crawlservpp::Main::Database::getThreadRunTime(), crawlservpp::Module::Database::log(), log(), crawlservpp::Helper::DateTime::now(), onClear(), onInit(), onPause(), onReset(), onTick(), onUnpause(), pause(), pauseByThread(), crawlservpp::Module::Database::prepare(), crawlservpp::Helper::DateTime::secondsToString(), setLast(), setStatusMessage(), crawlservpp::Main::Database::setThreadPauseTime(), crawlservpp::Main::Database::setThreadRunTime(), and crawlservpp::Module::sleepOnConnectionErrorS.

◆ onClear()

virtual void crawlservpp::Module::Thread::onClear ( )
protectedpure virtual

Clears the module.

Needs to be implemented by the (child) class for the specific module.

Implemented in crawlservpp::Module::Crawler::Thread, crawlservpp::Module::Extractor::Thread, crawlservpp::Module::Parser::Thread, and crawlservpp::Module::Analyzer::Thread.

Referenced by log().

◆ onInit()

virtual void crawlservpp::Module::Thread::onInit ( )
protectedpure virtual

Initializes the module.

Needs to be implemented by the (child) class for the specific module.

Implemented in crawlservpp::Module::Crawler::Thread, crawlservpp::Module::Extractor::Thread, crawlservpp::Module::Parser::Thread, and crawlservpp::Module::Analyzer::Thread.

Referenced by log().

◆ onPause()

virtual void crawlservpp::Module::Thread::onPause ( )
protectedpure virtual

Pauses the module.

Needs to be implemented by the (child) class for the specific module.

Implemented in crawlservpp::Module::Crawler::Thread, crawlservpp::Module::Extractor::Thread, crawlservpp::Module::Parser::Thread, and crawlservpp::Module::Analyzer::Thread.

Referenced by log().

◆ onReset()

virtual void crawlservpp::Module::Thread::onReset ( )
protectedpure virtual

Resets the module.

Needs to be implemented by the (child) class for the specific module.

Implemented in crawlservpp::Module::Crawler::Thread, crawlservpp::Module::Extractor::Thread, crawlservpp::Module::Parser::Thread, and crawlservpp::Module::Analyzer::Thread.

Referenced by log().

◆ onTick()

virtual void crawlservpp::Module::Thread::onTick ( )
protectedpure virtual

Performs a module tick.

Needs to be implemented by the (child) class for the specific module.

Implemented in crawlservpp::Module::Crawler::Thread, crawlservpp::Module::Extractor::Thread, crawlservpp::Module::Parser::Thread, and crawlservpp::Module::Analyzer::Thread.

Referenced by log().

◆ onUnpause()

virtual void crawlservpp::Module::Thread::onUnpause ( )
protectedpure virtual

Unpauses the module.

Needs to be implemented by the (child) class for the specific module.

Implemented in crawlservpp::Module::Crawler::Thread, crawlservpp::Module::Extractor::Thread, crawlservpp::Module::Parser::Thread, and crawlservpp::Module::Analyzer::Thread.

Referenced by log().

◆ operator=() [1/2]

Thread& crawlservpp::Module::Thread::operator= ( Thread )
delete

Deleted copy assignment operator.

◆ operator=() [2/2]

Thread& crawlservpp::Module::Thread::operator= ( Thread &&  )
delete

Deleted move assignment operator.

◆ pause()

bool crawlservpp::Module::Thread::pause ( )

Pauses the thread.

Warning
May not be used by the thread itself!
Returns
True, if the thread has successfully been paused. False, if the thread is not pausable at the moment.
See also
allowPausing, disallowPausing

References crawlservpp::Main::Database::setThreadStatus().

Referenced by log().

◆ pauseByThread()

void crawlservpp::Module::Thread::pauseByThread ( )
protected

◆ reset()

void crawlservpp::Module::Thread::reset ( )

Will reset the thread before the next tick.

◆ setLast()

void crawlservpp::Module::Thread::setLast ( std::uint64_t  lastId)
protected

Sets the last ID processed by the thread.

Also sets the number of processed IDs, make sure to increment it before if the ID has been processed.

Warning
May only be used by the thread itself, not by the main thread!
Parameters
lastIdThe last ID processed by the thread.
See also
incrementProcessed, incrementLast, Main::Database::setThreadLast

References database, and crawlservpp::Module::Database::setThreadLast().

Referenced by log(), crawlservpp::Module::Parser::Thread::onReset(), crawlservpp::Module::Extractor::Thread::onReset(), and crawlservpp::Module::Crawler::Thread::onReset().

◆ setProgress()

void crawlservpp::Module::Thread::setProgress ( float  newProgress)
protected

Sets the progress of the thread.

Warning
May only be used by the thread itself, not by the main thread!
Parameters
newProgressThe new progress of the thread, between 0.f (none), and 1.f (done).
See also
Main::Database::setThreadProgress

References database, and crawlservpp::Module::Database::setThreadProgress().

Referenced by crawlservpp::Module::Analyzer::Thread::finished(), crawlservpp::Module::Analyzer::Algo::TermsOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::ExtractIds::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::CorpusGenerator::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::WordsOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::Assoc::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::AssocOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::AllTokens::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::Empty::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::SentimentOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::TopicModelling::onAlgoInit(), crawlservpp::Module::Parser::Thread::onReset(), crawlservpp::Module::Extractor::Thread::onReset(), crawlservpp::Module::Crawler::Thread::onReset(), crawlservpp::Module::Analyzer::Thread::onTick(), crawlservpp::Module::Parser::Thread::onTick(), crawlservpp::Module::Extractor::Thread::onTick(), crawlservpp::Module::Analyzer::Algo::TermsOverTime::resetAlgo(), crawlservpp::Module::Analyzer::Algo::ExtractIds::resetAlgo(), crawlservpp::Module::Analyzer::Algo::WordsOverTime::resetAlgo(), crawlservpp::Module::Analyzer::Algo::Assoc::resetAlgo(), crawlservpp::Module::Analyzer::Algo::AssocOverTime::resetAlgo(), crawlservpp::Module::Analyzer::Algo::AllTokens::resetAlgo(), crawlservpp::Module::Analyzer::Algo::SentimentOverTime::resetAlgo(), and crawlservpp::Module::Analyzer::Algo::TopicModelling::resetAlgo().

◆ setStatusMessage()

void crawlservpp::Module::Thread::setStatusMessage ( const std::string &  statusMessage)
protected

Sets the status message of the thread.

Warning
May only be used by the thread itself, not by the main thread!
Note
String views cannot be used, because they are not supported by the API for the MySQL database.
Parameters
statusMessageConstant reference to a string containing the new status message to be set.
See also
Main::Database::setThreadStatus

References database, and crawlservpp::Main::Database::setThreadStatus().

Referenced by crawlservpp::Module::Analyzer::Thread::cleanUpQueries(), crawlservpp::Module::Analyzer::Thread::finished(), log(), crawlservpp::Module::Analyzer::Algo::TermsOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::ExtractIds::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::CorpusGenerator::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::WordsOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::Assoc::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::AssocOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::AllTokens::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::Empty::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::SentimentOverTime::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::TopicModelling::onAlgoInit(), crawlservpp::Module::Analyzer::Algo::CorpusGenerator::onAlgoTick(), crawlservpp::Module::Analyzer::Algo::AllTokens::onAlgoTick(), crawlservpp::Module::Analyzer::Algo::TopicModelling::onAlgoTick(), crawlservpp::Module::Parser::Thread::onClear(), crawlservpp::Module::Extractor::Thread::onClear(), crawlservpp::Module::Parser::Thread::onReset(), crawlservpp::Module::Extractor::Thread::onReset(), crawlservpp::Module::Crawler::Thread::onReset(), crawlservpp::Module::Parser::Thread::onTick(), crawlservpp::Module::Extractor::Thread::onTick(), crawlservpp::Module::Analyzer::Algo::TermsOverTime::resetAlgo(), crawlservpp::Module::Analyzer::Algo::ExtractIds::resetAlgo(), crawlservpp::Module::Analyzer::Algo::WordsOverTime::resetAlgo(), crawlservpp::Module::Analyzer::Algo::Assoc::resetAlgo(), crawlservpp::Module::Analyzer::Algo::AssocOverTime::resetAlgo(), crawlservpp::Module::Analyzer::Algo::AllTokens::resetAlgo(), crawlservpp::Module::Analyzer::Algo::SentimentOverTime::resetAlgo(), crawlservpp::Module::Analyzer::Algo::TopicModelling::resetAlgo(), and crawlservpp::Module::Analyzer::Thread::uploadResult().

◆ sleep()

void crawlservpp::Module::Thread::sleep ( std::uint64_t  ms) const
protected

Lets the thread sleep for the specified number of milliseconds.

The sleep will be interrupted if the thread is stopped.

Thread-safe: Can be used by both the module and the main thread.

Parameters
msThe number of milliseconds for the thread to sleep, if it is not stopped.

References crawlservpp::Module::sleepMs.

Referenced by crawlservpp::Module::Analyzer::Algo::CorpusGenerator::onAlgoTick(), crawlservpp::Module::Crawler::Thread::onReset(), crawlservpp::Module::Analyzer::Thread::onTick(), crawlservpp::Module::Parser::Thread::onTick(), and crawlservpp::Module::Extractor::Thread::onTick().

◆ start()

void crawlservpp::Module::Thread::start ( )

Starts running the thread.

Warning
May not be used by the thread itself!

◆ stop()

void crawlservpp::Module::Thread::stop ( )

Shuts down the thread.

Note
end() needs to be called afterwards to wait for the thread.
Warning
May not be used by the thread itself!

References unpause().

◆ unpause()

void crawlservpp::Module::Thread::unpause ( )

Unpauses the thread.

Warning
May not be used by the thread itself!

References crawlservpp::Main::Database::setThreadStatus().

Referenced by interrupt(), and stop().

◆ warpTo()

void crawlservpp::Module::Thread::warpTo ( std::uint64_t  target)

Jumps to the specified target ID ("time travel").

Skips the normal process of determining the next ID once the current ID has been processed.

Thread-safe: Can be used by both the module and the main thread.

Parameters
targetThe target ID that should be processed next.
Exceptions
Module::Thread::Exceptionif no target is specified, i.e. the target ID is zero.
See also
getWarpedOverAndReset

Member Data Documentation

◆ configuration

std::string crawlservpp::Module::Thread::configuration
protected

JSON string of the configuration used by the thread.

See also
Main::Database::getConfiguration

Referenced by Thread().

◆ database

Database crawlservpp::Module::Thread::database
protected

Database connection for the thread.

Referenced by incrementLast(), isLogLevel(), log(), pauseByThread(), setLast(), setProgress(), setStatusMessage(), and Thread().

◆ urlListNamespace

std::string crawlservpp::Module::Thread::urlListNamespace
protected

◆ websiteNamespace

std::string crawlservpp::Module::Thread::websiteNamespace
protected

The documentation for this class was generated from the following files: