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

Function GetCurrentThreadPool

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

Source from the content-addressed store, hash-verified

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

Callers 1

OwnsThisThreadMethod · 0.85

Calls 2

GetPoolTlsIndexFunction · 0.85
WinErrorMessageFunction · 0.85

Tested by

no test coverage detected