|
AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface
|
A class which wraps a std::future<void> and provides debugging output to stderr.
This is a specialization of drama::Future<T> for T=void.
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<void> with a drama::Future<void>, 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<void> myFuture = std::async(...);
with something like
drama::Future<void> 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<void> "%" ...' The '' character is replaced by the "name" supplied to the constructor or SetName() method.
#include "debugfuture.hh"
Inherits std::future< void >.
Public Member Functions | |
| Future (const Future &)=delete | |
| Copy constructor = deleted. | |
| Future (const std::string &name="unnamed", bool logOn=false) noexcept | |
| Construct a drama::Future<void> object. | |
| ~Future () | |
| Destructor. | |
| void | 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<void> | |
| 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 by