#include <Activity.h>
Public Member Functions | |
| DeclareActivity (const ACTIVITY *activity) noexcept | |
Push the argument Activity onto the current thread's Activity stack in the constructor, and pop it off in the destructor.
An exception captures the activities in force when it is THROWN with Execution::Throw (), not those in force when it was constructed. So an exception built in one context (a static const, say) and thrown in another reports the context of the throw. Throw () fills in only an exception that specified no activities of its own (any Stroika Exception<>), and a bare throw X{} gets none. For a third-party exception, wrap it in a NestedException and Throw () that.
Each activity's AsString () runs at that Throw (), while its DeclareActivity is still in scope - so a LazyEvalActivity's lambda may capture by reference.
Definition at line 153 of file Activity.h.
|
noexcept |
The caller must always declare an activity object (an Activity<> or LazyEvalActivity<>) whose address can be taken, and whose lifetime exceeds that of the DeclareActivity object.
This is allowed to facilitate examples like:
\code
DeclareActivity declareActivity { flag ? &kSomeActivity_ : nullptr }; // so we only conditionally declare the activity
\endcode
I considered using optional<ACTIVITY> - but tricky since we pass in pointer - and really not much point. This has practically zero
overhead, and is easy enough to understand and use.
Definition at line 56 of file Activity.inl.