![]() |
libcyberradio
22.01.24
|
Base class for a thread object, based on Boost Threads. More...
#include <Thread.h>
Public Member Functions | |
| Thread (const std::string &name="", const std::string &cls="") | |
| Creates a Thread object. More... | |
| Thread (const Thread &src) | |
| Creates a Thread object by copying another Thread object. More... | |
| virtual Thread & | operator= (const Thread &src) |
| Creates a Thread object by assignment from another Thread object. More... | |
| virtual | ~Thread () |
| Destroys a Thread object. | |
| virtual void | start () |
| Starts thread processing. | |
| virtual void | run ()=0 |
| Executes the main processing loop for the thread. More... | |
| virtual void | interrupt () |
| Interrupts (stops) the thread. | |
| virtual void | sleep (double secs) |
| Pauses thread execution for a given time, checking for user interrupts during that time. More... | |
| virtual bool | isRunning () const |
| Determines if the thread is running or not. More... | |
| virtual void | setName (const std::string &name) |
| Sets the name of the thread. More... | |
| virtual void | setClass (const std::string &cls) |
| Sets the class identifer string for the thread. More... | |
| virtual boost::thread::id | getId () const |
| Gets the identifier of the underlying Boost thread. More... | |
| virtual std::string | getIdString () const |
| Gets the identifier string for this thread. More... | |
| virtual void | onInterrupt () |
| Executes code that must run when the thread is interrupted. More... | |
| virtual void | onException (const std::exception &ex) |
| Executes code that must run when an unhandled exception occurs within the thread. More... | |
Base class for a thread object, based on Boost Threads.
Basic procedure for using this class:
| Thread | ( | const std::string & | name = "", |
| const std::string & | cls = "" |
||
| ) |
Creates a Thread object.
| name | Name of this thread. |
| cls | Class identifier string for this thread. |
Definition at line 19 of file Thread.cpp.
Creates a Thread object by copying another Thread object.
| src | The Thread object being copied. |
Definition at line 27 of file Thread.cpp.
|
virtual |
Gets the identifier of the underlying Boost thread.
Definition at line 91 of file Thread.cpp.
|
virtual |
Gets the identifier string for this thread.
Definition at line 96 of file Thread.cpp.
|
virtual |
Determines if the thread is running or not.
Definition at line 72 of file Thread.cpp.
|
virtual |
Executes code that must run when an unhandled exception occurs within the thread.
The base-class method does nothing. Override this method in derived classes to perform custom exception processing.
| ex | The exception that occurred. |
Definition at line 110 of file Thread.cpp.
|
virtual |
Executes code that must run when the thread is interrupted.
The base-class method does nothing. Override this method in derived classes to perform custom interrupt processing.
Definition at line 87 of file Thread.cpp.
Creates a Thread object by assignment from another Thread object.
| src | The Thread object being copied. |
Definition at line 34 of file Thread.cpp.
|
pure virtual |
Executes the main processing loop for the thread.
Override this method in derived classes to perform thread processing.
Implemented in FlowControlClient, StatusReceiver, and UdpStatusReceiver.
|
virtual |
Sets the class identifer string for the thread.
| cls | The new class identifer for the thread. |
Definition at line 82 of file Thread.cpp.
|
virtual |
Sets the name of the thread.
| name | The new name of the thread. |
Definition at line 77 of file Thread.cpp.
|
virtual |
Pauses thread execution for a given time, checking for user interrupts during that time.
The sleep timer has microsecond resolution.
| secs | Number of seconds to "sleep". |
Definition at line 65 of file Thread.cpp.