mirror of
https://github.com/tnodir/fort
synced 2024-11-15 09:25:40 +00:00
UI: IocContainer: Inline the TlsGetValue().
This commit is contained in:
parent
19845e5b9f
commit
bad1b2fafa
@ -2,37 +2,9 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <qt_windows.h>
|
||||
|
||||
#include "iocservice.h"
|
||||
|
||||
namespace {
|
||||
|
||||
int g_nextTypeId = 0;
|
||||
int g_tlsIndex = -1;
|
||||
|
||||
void createTlsIndex()
|
||||
{
|
||||
if (g_tlsIndex == -1) {
|
||||
g_tlsIndex = TlsAlloc();
|
||||
if (g_tlsIndex == -1) {
|
||||
qWarning() << "TlsAlloc error";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void deleteTlsIndex()
|
||||
{
|
||||
if (g_tlsIndex != -1) {
|
||||
TlsFree(g_tlsIndex);
|
||||
g_tlsIndex = -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
int IocContainer::g_tlsIndex = -1;
|
||||
|
||||
IocContainer::IocContainer(QObject *parent) : QObject(parent) { }
|
||||
|
||||
@ -118,12 +90,26 @@ bool IocContainer::pinToThread()
|
||||
return TlsSetValue(g_tlsIndex, this);
|
||||
}
|
||||
|
||||
IocContainer *IocContainer::getPinned()
|
||||
void IocContainer::createTlsIndex()
|
||||
{
|
||||
return static_cast<IocContainer *>(TlsGetValue(g_tlsIndex));
|
||||
if (g_tlsIndex == -1) {
|
||||
g_tlsIndex = TlsAlloc();
|
||||
if (g_tlsIndex == -1) {
|
||||
qWarning() << "TlsAlloc error";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IocContainer::deleteTlsIndex()
|
||||
{
|
||||
if (g_tlsIndex != -1) {
|
||||
TlsFree(g_tlsIndex);
|
||||
g_tlsIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
int IocContainer::getNextTypeId()
|
||||
{
|
||||
static int g_nextTypeId = 0;
|
||||
return g_nextTypeId++;
|
||||
}
|
||||
|
@ -4,6 +4,9 @@
|
||||
#include <QObject>
|
||||
#include <QVarLengthArray>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <qt_windows.h>
|
||||
|
||||
#include "iocservice.h"
|
||||
|
||||
using IocObject = void;
|
||||
@ -79,7 +82,10 @@ public:
|
||||
|
||||
bool pinToThread();
|
||||
|
||||
static IocContainer *getPinned();
|
||||
inline static IocContainer *getPinned()
|
||||
{
|
||||
return static_cast<IocContainer *>(TlsGetValue(g_tlsIndex));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static int getTypeId()
|
||||
@ -101,10 +107,16 @@ private:
|
||||
void tearDown(int typeId);
|
||||
void autoDelete(int typeId);
|
||||
|
||||
static void createTlsIndex();
|
||||
static void deleteTlsIndex();
|
||||
|
||||
static int getNextTypeId();
|
||||
|
||||
private:
|
||||
static int g_tlsIndex;
|
||||
|
||||
int m_size = 0;
|
||||
|
||||
QVarLengthArray<IocObject *, IOC_DEFAULT_SIZE> m_objects;
|
||||
QVarLengthArray<quint8, IOC_DEFAULT_SIZE> m_objectFlags;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user