MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / thread_main_body

Function thread_main_body

TactilityKernel/source/concurrent/thread.cpp:54–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54static void thread_main_body(void* context) {
55 check(context != nullptr);
56 auto* thread = static_cast<Thread*>(context);
57
58 // Save Thread instance pointer to task local storage
59 check(pvTaskGetThreadLocalStoragePointer(nullptr, LOCAL_STORAGE_SELF_POINTER_INDEX) == nullptr);
60 vTaskSetThreadLocalStoragePointer(nullptr, LOCAL_STORAGE_SELF_POINTER_INDEX, thread);
61
62 LOG_I(TAG, "Starting %s", thread->name.c_str()); // No need to lock as we don't allow mutation after thread start
63 check(thread->state == THREAD_STATE_STARTING);
64 thread_set_state_internal(thread, THREAD_STATE_RUNNING);
65
66 int32_t result = thread->mainFunction(thread->mainFunctionContext);
67 thread->lock();
68 thread->callbackResult = result;
69 thread->unlock();
70
71 check(thread->state == THREAD_STATE_RUNNING);
72 thread_set_state_internal(thread, THREAD_STATE_STOPPED);
73 LOG_I(TAG, "Stopped %s", thread->name.c_str()); // No need to lock as we don't allow mutation after thread start
74
75 vTaskSetThreadLocalStoragePointer(nullptr, LOCAL_STORAGE_SELF_POINTER_INDEX, nullptr);
76
77 thread->lock();
78 thread->taskHandle = nullptr;
79 thread->unlock();
80
81 vTaskDelete(nullptr);
82}
83
84extern "C" {
85

Callers

nothing calls this directly

Calls 4

checkFunction · 0.50
lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected