DRTVWR-494: Use std::thread::id for LLThread::currentID().
LLThread::currentID() used to return a U32, a distinct unsigned value incremented by explicitly constructing LLThread or by calling LLThread:: registerThreadID() early in a thread launched by other means. The latter imposed an unobvious requirement on new code based on std::thread. Using std::thread::id instead delegates to the compiler/library the problem of distinguishing threads launched by any means. Change lots of explicit U32 declarations. Introduce LLThread::id_t typedef to avoid having to run around fixing uses again if we later revisit this decision. LLMutex, which stores an LLThread::id_t, wants a distinguished value meaning NO_THREAD, and had an enum with that name. But as std::thread::id promises that the default-constructed value is distinct from every valid value, NO_THREAD becomes unnecessary and goes away. Because LLMutex now stores LLThread::id_t instead of U32, make llmutex.h #include "llthread.h" instead of the other way around. This makes LLMutex an incomplete type within llthread.h, so move LLThread::lockData() and unlockData() to the .cpp file. Similarly, remove llrefcount.h's #include "llmutex.h" to break circularity; instead forward-declare LLMutex. It turns out that a number of source files assumed that #include "llthread.h" would get the definition for LLMutex. Sprinkle #include "llmutex.h" as needed. In the SAFE_SSL code in llcorehttp/httpcommon.cpp, there's an ssl_thread_id() callback that returns an unsigned long to the SSL library. When LLThread:: currentID() was U32, we could simply return that. But std::thread::id is very deliberately opaque, and can't be reinterpret_cast to unsigned long. Fortunately it can be hashed because std::hash is specialized with that type.
Showing
- indra/llcommon/llmutex.cpp 6 additions, 7 deletionsindra/llcommon/llmutex.cpp
- indra/llcommon/llmutex.h 5 additions, 9 deletionsindra/llcommon/llmutex.h
- indra/llcommon/llrefcount.h 2 additions, 1 deletionindra/llcommon/llrefcount.h
- indra/llcommon/llthread.cpp 19 additions, 17 deletionsindra/llcommon/llthread.cpp
- indra/llcommon/llthread.h 6 additions, 18 deletionsindra/llcommon/llthread.h
- indra/llcommon/lluuid.cpp 2 additions, 1 deletionindra/llcommon/lluuid.cpp
- indra/llcommon/llworkerthread.h 1 addition, 0 deletionsindra/llcommon/llworkerthread.h
- indra/llcorehttp/httpcommon.cpp 3 additions, 1 deletionindra/llcorehttp/httpcommon.cpp
- indra/llmessage/llbuffer.cpp 1 addition, 0 deletionsindra/llmessage/llbuffer.cpp
- indra/llmessage/llbufferstream.cpp 1 addition, 0 deletionsindra/llmessage/llbufferstream.cpp
- indra/llmessage/llproxy.h 1 addition, 0 deletionsindra/llmessage/llproxy.h
- indra/llplugin/llpluginmessagepipe.h 1 addition, 0 deletionsindra/llplugin/llpluginmessagepipe.h
- indra/llvfs/llvfs.h 1 addition, 0 deletionsindra/llvfs/llvfs.h
Loading
Please register or sign in to comment