Adding TLS abstraction.
This commit is contained in:
@@ -89,6 +89,14 @@ SleepResult AlertableSleep(std::chrono::duration<Rep, Period> duration) {
|
||||
std::chrono::duration_cast<std::chrono::microseconds>(duration));
|
||||
}
|
||||
|
||||
typedef uint32_t TlsHandle;
|
||||
constexpr TlsHandle kInvalidTlsHandle = UINT_MAX;
|
||||
|
||||
TlsHandle AllocateTlsHandle();
|
||||
bool FreeTlsHandle(TlsHandle handle);
|
||||
uintptr_t GetTlsValue(TlsHandle handle);
|
||||
bool SetTlsValue(TlsHandle handle, uintptr_t value);
|
||||
|
||||
// Results for a WaitHandle operation.
|
||||
enum class WaitResult {
|
||||
// The state of the specified object is signaled.
|
||||
|
||||
@@ -96,6 +96,18 @@ SleepResult AlertableSleep(std::chrono::microseconds duration) {
|
||||
return SleepResult::kSuccess;
|
||||
}
|
||||
|
||||
TlsHandle AllocateTlsHandle() { return TlsAlloc(); }
|
||||
|
||||
bool FreeTlsHandle(TlsHandle handle) { return TlsFree(handle) ? true : false; }
|
||||
|
||||
uintptr_t GetTlsValue(TlsHandle handle) {
|
||||
return reinterpret_cast<uintptr_t>(TlsGetValue(handle));
|
||||
}
|
||||
|
||||
bool SetTlsValue(TlsHandle handle, uintptr_t value) {
|
||||
return TlsSetValue(handle, reinterpret_cast<void*>(value)) ? true : false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
class Win32Handle : public T {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user