AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface

◆ TaskPtr()

std::weak_ptr< Task > drama::Task::TaskPtr ( )
inlineinherited

Returns a weak pointer to the task.

This operator allows references to the task to be passed around various locations and used as needed.

Note
If the Task object itself was created as a std::shared_pnt, then the return values will be linked to that pointer. If it is not, then an internal shared_pnt will be created.
If the task object was created as std::shared_pnt using std::make_shared(), then it may use a internal shared_pnt anyway, particularly if invoked before the constructor is completed (e.g. in the sub-class constructor). That causes an inefficiency, but no real problem.
There is some expected behavior here that is not defined prior to C++17, but does work reliably on GNU C++ and CLang when compiled as C++11 code.
Returns
A weak pointer to the task. Note that it is expected the user will only convert this to a std::shared_ptr for short periods, such that the task does not shut down whilst user code holding it (immediately taking the drama lock makes this safer).
Examples
monitor1.cpp, monitor2.cpp, and tocker.cpp.