13 #ifndef __UT_TASKSTATE_H_INCLUDED__
14 #define __UT_TASKSTATE_H_INCLUDED__
16 #ifndef __TBB_show_deprecation_message_task_H
17 #define __TBB_show_deprecation_message_task_H
18 #define UT_TASK_STATE_RESTORE_DEPRECATION_MESSAGE
68 : myArenaAndGroupRefCount(0)
71 "This is just to check that the union is putting the two pointers "
72 "in the same place.");
78 UT_ASSERT_P(myArenaAndGroupRefCount.relaxedLoad() == 0);
79 UT_ASSERT_P(myArenaAndGroup.relaxedLoad() ==
nullptr || myWaitingTasks.relaxedLoad() == plugged());
87 myStatus.relaxedStore(FREE);
88 UT_ASSERT_P(myArenaAndGroupRefCount.relaxedLoad() == 0);
92 myArenaAndGroup.relaxedStore(
nullptr);
98 auto state = myStatus.relaxedLoad();
99 return state == DONE_NO_ARENA || state == DONE_WITH_ARENA;
107 auto state = myStatus.relaxedLoad();
108 if (state == DONE_WITH_ARENA || state == DONE_NO_ARENA || state == BUSY_NO_ARENA)
118 myArenaAndGroupRefCount.add(1);
122 state = myStatus.compare_swap(FREE, run_in_task_arena ? BUSY_WITH_ARENA : BUSY_NO_ARENA);
124 if (state == DONE_NO_ARENA || state == BUSY_NO_ARENA || (!run_in_task_arena && state == FREE))
125 myArenaAndGroupRefCount.add(-1);
126 else if (state == DONE_WITH_ARENA)
136 UT_ASSERT_MSG(0,
"This is untested code. Note that calling code in the build is now unused."
137 " If myArenaAndGroup was used before, it must be used on subsequent executes.");
138 if (myStatus.compare_swap(DONE_NO_ARENA, BUSY_NO_ARENA) == DONE_NO_ARENA)
144 UT_ASSERT(myArenaAndGroupRefCount.relaxedLoad() == 0);
145 myArenaAndGroup.relaxedStore(
nullptr);
148 return BUSY_NO_ARENA;
155 UT_ASSERT_P(myStatus.relaxedLoad() == BUSY_NO_ARENA || myStatus.relaxedLoad() == DONE_NO_ARENA);
162 old = myWaitingTasks;
163 if (old == plugged())
179 while (myWaitingTasks.compare_swap(old, proxy) != old);
195 while (proxy !=
nullptr)
202 myStatus.exchange(DONE_NO_ARENA);
207 myStatus.exchange(run_in_task_arena ? DONE_WITH_ARENA : DONE_NO_ARENA);
217 UT_VERIFY(myWaitingTasks.exchange(plugged()) ==
nullptr);
220 myStatus.exchange(DONE_NO_ARENA);
234 UT_ASSERT_P(myArenaAndGroupRefCount.relaxedLoad() > 0 &&
235 (myStatus.relaxedLoad() == BUSY_WITH_ARENA || myStatus.relaxedLoad() == DONE_WITH_ARENA));
236 myArenaAndGroup.relaxedStore(p);
240 UT_ASSERT_P(myArenaAndGroupRefCount.relaxedLoad() > 0 &&
241 (myStatus.relaxedLoad() == BUSY_WITH_ARENA || myStatus.relaxedLoad() == DONE_WITH_ARENA));
242 return myArenaAndGroup.relaxedLoad();
248 UT_ASSERT_P(myStatus.relaxedLoad() == DONE_WITH_ARENA);
249 if (myArenaAndGroupRefCount.add(-1) == 0)
256 auto *arena_group = myArenaAndGroup.exchange(
nullptr);
269 #ifdef UT_TASK_STATE_RESTORE_DEPRECATION_MESSAGE
270 #undef __TBB_show_deprecation_message_task_H
271 #undef UT_TASK_STATE_RESTORE_DEPRECATION_MESSAGE
274 #endif // __UT_TASKSTATE_H_INCLUDED__
Thread has acquired responsibility to evaluate node.
void markAsDoneNoThread()
Non-threaded version of marking as done.
#define SYS_STATIC_ASSERT_MSG(expr, msg)
A task node for managing which thread is currently working on a given task.
fallback_uintptr uintptr_t
ArenaAndGroup * getArenaGroup() const
void markAsDone(UT_Task *parent_task, bool run_in_task_arena)
SYS_AtomicPtr< UT_TaskStateProxy > myWaitingTasks
#define UT_ASSERT_MSG(ZZ,...)
TaskStatus tryMarkAsBusy(bool run_in_task_arena=false)
void spawnChild(UT_Task &task)
bool isDone() const
Test whether the task state is marked as DONE.
void setAndRetainArenaGroup(ArenaAndGroup *p)
Another thread is busy evaluating the node without an arena.
Another thread is busy evaluating the node with an arena.
std::pair< UT_TaskArena, UT_TaskGroup > ArenaAndGroup
void addWaitingTask(UT_Task &parent_task)
SYS_AtomicPtr< ArenaAndGroup > myArenaAndGroup
TaskStatus relaxedLoadStatus() const
This does a fast (non-atomic) check of the status.
TaskStatus tryMarkAsBusyFromDone()