Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Activity.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
6
7 /*
8 ********************************************************************************
9 ************************************** Activity ********************************
10 ********************************************************************************
11 */
12 template <typename STRINGISH_T>
13 constexpr Activity<STRINGISH_T>::Activity (const STRINGISH_T& arg)
14 : fArg_{arg}
15 {
16 }
17 template <typename CTOR_ARG>
18 Characters::String Activity<CTOR_ARG>::AsString () const
19 {
20 return fArg_;
21 }
22
23 /*
24 ********************************************************************************
25 ************************ LazyEvalActivity<CTOR_ARG> ****************************
26 ********************************************************************************
27 */
28 template <typename CTOR_ARG>
29 constexpr LazyEvalActivity<CTOR_ARG>::LazyEvalActivity (const CTOR_ARG& arg)
30 requires (is_invocable_r_v<Characters::String, CTOR_ARG>)
31 : fArg_{arg}
32 {
33 }
34 template <typename CTOR_ARG>
35 Characters::String LazyEvalActivity<CTOR_ARG>::AsString () const
36 {
37 return fArg_ (); // what makes this more efficient is that we can just capture data in a lambda (by reference)
38 // and just invoke that logic during exception processing when we need to convert the activity to a string rep
39 }
40 /*
41 ********************************************************************************
42 *************************** DeclareActivity<ACTIVITY> **************************
43 ********************************************************************************
44 */
45 template <typename ACTIVITY>
46 inline DeclareActivity<ACTIVITY>::DeclareActivity (const ACTIVITY* activity) noexcept
47 : fNewTopOfStackElt_{activity, Private_::Activities_::sTop_}
48 {
49 // no locks needed because the variables are thread local
50 if (activity != nullptr) {
51 Private_::Activities_::sTop_ = &fNewTopOfStackElt_;
52 }
53 }
54 template <typename ACTIVITY>
55 inline DeclareActivity<ACTIVITY>::~DeclareActivity ()
56 {
57 if (fNewTopOfStackElt_.fActivity != nullptr) {
58 // no locks needed because the variables are thread local
59 Assert (Private_::Activities_::sTop_ == &fNewTopOfStackElt_);
60 Private_::Activities_::sTop_ = Private_::Activities_::sTop_->fPrev;
61 }
62 }
63
64}