MCPcopy Create free account
hub / github.com/apache/arrow / GetCurrentThreadPool

Function GetCurrentThreadPool

cpp/src/arrow/util/thread_pool.cc:662–677  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

660} // namespace
661
662static ThreadPool* GetCurrentThreadPool() {
663 // Preserve the caller's last-error value while also detecting TLS failures.
664 DWORD original_error = GetLastError();
665 // Ensure a successful TlsGetValue() leaves GetLastError() == 0.
666 SetLastError(0);
667 auto* pool = static_cast<ThreadPool*>(TlsGetValue(GetPoolTlsIndex()));
668 DWORD tls_error = GetLastError();
669 if (tls_error != 0) {
670 // No need to restore original_error here: ARROW_LOG(FATAL) aborts the process.
671 ARROW_LOG(FATAL) << "TlsGetValue failed for thread pool TLS: "
672 << WinErrorMessage(tls_error);
673 }
674 // Restore the caller's last-error value.
675 SetLastError(original_error);
676 return pool;
677}
678
679static void SetCurrentThreadPool(ThreadPool* pool) {
680 BOOL ok = TlsSetValue(GetPoolTlsIndex(), pool);

Callers 1

OwnsThisThreadMethod · 0.85

Calls 2

GetPoolTlsIndexFunction · 0.85
WinErrorMessageFunction · 0.85

Tested by

no test coverage detected