void tt_thread_exit_ntv() { tt_thread_t *thread = (tt_thread_t *)FlsGetValue(tt_g_thread_fls_index); if (thread->detached) { _endthread(); } else { _endthreadex(TT_SUCCESS); } }
thread_specific_impl::object *thread_specific_impl::get_object() const { void *pobj = FlsGetValue(d->key); if(!pobj) { pobj = reinterpret_cast<void *>(d->base->clone()); if(!FlsSetValue(d->key,pobj)) { int err=GetLastError(); delete reinterpret_cast<object *>(pobj); throw system::system_error(system::error_code(err,system::system_category)); } } return reinterpret_cast<object *>(pobj); }
tt_result_t tt_thread_create_local_ntv(IN tt_thread_t *thread) { tt_thread_ntv_t *sys_thread = &thread->sys_thread; if (tt_g_numa_node_id_thread != TT_NUMA_NODE_ID_UNSPECIFIED) { __thread_bind_numa(GetCurrentThread(), (USHORT)tt_g_numa_node_id_thread); } TT_ASSERT(FlsGetValue(tt_g_thread_fls_index) == NULL); if (FlsSetValue(tt_g_thread_fls_index, (LPVOID)thread) == 0) { TT_ERROR_NTV("fail to set thread private data"); return TT_FAIL; } __thread_on_create(thread); return TT_SUCCESS; }
VOID WINAPI LogMessage(PVOID pFlsValue) { TCHAR szMsg[MAX_PATH]; // Check if we are in a fiber because this function can be called // outside a fiber execution if (IsThreadAFiber()) { PVOID pFiberData = GetCurrentFiber(); PCTSTR pszFlsValue = (PCTSTR)FlsGetValue(g_dwSlot); StringCchPrintf(szMsg, _countof(szMsg), TEXT("[0x%x - %s] %s\n"), pFiberData, (pszFlsValue == NULL) ? TEXT("'Null value'") : (PCTSTR)pszFlsValue, (pFlsValue == NULL) ? TEXT("'Null value'") : (PCTSTR)pFlsValue); } else { StringCchCopy(szMsg, _countof(szMsg), TEXT("No more a fiber...\n")); } /* Sends a string to the debugger for display. */ OutputDebugString(szMsg); }
LPVOID WINAPI TlsGetValue (DWORD id) { return FlsGetValue (id); }
ZyanStatus ZyanThreadTlsGetValue(ZyanThreadTlsIndex index, void** data) { *data = FlsGetValue(index); return ZYAN_STATUS_SUCCESS; }