AuroraRuntime/Source/Threading/Threads/TLSView.hpp

28 lines
686 B
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: TLSView.hpp
Date: 2021-6-12
Author: Reece
***/
#pragma once
namespace Aurora::Threading::Threads
{
class TLSViewImpl : public TLSView
{
public:
~TLSViewImpl();
void Remove(AuUInt64 key) override;
void *GetTLS(AuUInt64 key, AuMach length, bool noAutoCreate) override;
void *InitTLS(AuUInt64 key, AuMach length, const TlsCb &init, const TlsCb &deinit) override;
private:
void ConsiderRehash();
Primitives::SpinLock lock_;
AuHashMap<AuUInt64, AuPair<void*, TlsCb>> tls_;
AuUInt64 fence_ = 0;
};
}