AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface
|
A class which wraps a std::future<T> and provides debugging output to stderr.
The idea of this class is to help debug futures, which can cause unexpected hangs when get() and the destructor are invoked. The later are a particular issue as it may not be apparent when they are being invoked.
By replacing a type of std::future<T> with a drama::Future, you can arrange for debugging information to be output to stderr. Whilst the message output is similar for each such future, a name string can be supplied which allows you to distinguish each future.
A typical approach would replace something like
std::future<bool> myFuture = std::async(...);
with something like
drama::Future<bool> myFuture; myFuture.SetName("some string..."); myFuture = std::async(...);
By default, any such future results in the messages being output to stderr. Such messages are output if either the global log flag is true, or a local log flag is true. By default, the global log flag is true, and the local is false. but these can be enabled/disabled as required.
The messages are of the form 'drama::Future<%> "%" ...' where the first '' character is replace by typeinfo.name() on the template type. This string is compiler specific, particularly for built-in types. For example, in GCC 4.9, simple built in types use 'b' for bool, 'i' for integer, 'm' for unsigned long. Other compilers will vary. For void, 'void' is output in all cases. The second '' character is replaced by the "name" supplied to the constructor or SetName() method.
The | type returned by the future. |
#include "debugfuture.hh"
Inherits std::future< T >.
Public Member Functions | |
Future (const Future &)=delete | |
Copy constructor = deleted. | |
Future (const std::string &name="unnamed", bool logOn=false) noexcept | |
Construct a drama::Future object. | |
~Future () | |
Destructor. | |
T | get () |
Get value of future. | |
bool | GetLogState () const |
Return the state of the object specific logging flag. | |
void | LogOff () |
Turn logging off. | |
void | LogOn () |
Turn logging on. | |
Future & | operator= (BaseFuture &&rhs) noexcept |
Move assignment operator - source std::future<T> | |
Future & | operator= (const Future &)=delete |
Assignment operator (non-move) - deleted. | |
Future & | operator= (Future &&rhs) noexcept |
Move assignment operator. | |
void | SetName (const std::string &newName) |
Set the name of this object - as used in logging messages. | |
Static Public Member Functions | |
static bool | GetGlobalLogState () |
Return the state of the global logging flag. | |
static void | GlobalLogOff () |
Turn logging off - global. | |
static void | GlobalLogOn () |
Turn logging on - global. | |
Click here for the DRAMA home page and here for the AAO home page.
For more information, contact tony.farrell@mq.edu.au
Generated on Thu Dec 12 2024 23:07:35 for AAO DRAMA/DRAMA2 C++ Interface by 1.9.8