AuroraRuntime/Source/Threading/Threads/TLSView.hpp

28 lines
689 B
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
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, std::pair<void*, TlsCb>> tls_;
AuUInt64 fence_ = 0;
};
}