Cosmetic: Copyright years were updated
[ode.git] / ode / src / odetls.h
blob21560583e649c5a4020f0395da52cd02e581fac2
1 /*************************************************************************
2 * *
3 * Thread local storage access stub for Open Dynamics Engine, *
4 * Copyright (C) 2008-2024 Oleh Derevenko. All rights reserved. *
5 * Email: odar@eleks.com (change all "a" to "e") *
6 * *
7 * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
8 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
9 * *
10 * *
11 * This library is free software; you can redistribute it and/or *
12 * modify it under the terms of EITHER: *
13 * (1) The GNU Lesser General Public License as published by the Free *
14 * Software Foundation; either version 2.1 of the License, or (at *
15 * your option) any later version. The text of the GNU Lesser *
16 * General Public License is included with this library in the *
17 * file LICENSE.TXT. *
18 * (2) The BSD-style license that is included with this library in *
19 * the file LICENSE-BSD.TXT. *
20 * *
21 * This library is distributed in the hope that it will be useful, *
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
24 * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
25 * *
26 *************************************************************************/
30 ODE Thread Local Storage access stub interface.
35 #ifndef _ODE_ODETLS_H_
36 #define _ODE_ODETLS_H_
39 #include "odeou.h"
42 #if dTLS_ENABLED
45 using _OU_NAMESPACE::tlsvaluetype;
46 using _OU_NAMESPACE::HTLSKEY;
47 using _OU_NAMESPACE::CThreadLocalStorage;
50 struct TrimeshCollidersCache;
53 enum EODETLSKIND
55 OTK__MIN,
57 OTK_AUTOCLEANUP = OTK__MIN,
58 OTK_MANUALCLEANUP,
60 OTK__MAX,
62 OTK__DEFAULT = OTK_AUTOCLEANUP,
65 enum EODETLSITEM
67 OTI_DATA_ALLOCATION_FLAGS,
68 OTI_TRIMESH_TRIMESH_COLLIDER_CACHE,
70 OTI__MAX,
74 class COdeTls
76 public:
77 static bool Initialize(EODETLSKIND tkTLSKind);
78 static void Finalize(EODETLSKIND tkTLSKind);
80 static void CleanupForThread();
82 public:
83 static unsigned GetDataAllocationFlags(EODETLSKIND tkTLSKind)
85 // Must be a safe call as it is used to test if TLS slot is allocated at all
86 return (unsigned)(sizeint)CThreadLocalStorage::GetStorageValue(m_ahtkStorageKeys[tkTLSKind], OTI_DATA_ALLOCATION_FLAGS);
89 static void SignalDataAllocationFlags(EODETLSKIND tkTLSKind, unsigned uFlagsMask)
91 unsigned uCurrentFlags = (unsigned)(sizeint)CThreadLocalStorage::UnsafeGetStorageValue(m_ahtkStorageKeys[tkTLSKind], OTI_DATA_ALLOCATION_FLAGS);
92 CThreadLocalStorage::UnsafeSetStorageValue(m_ahtkStorageKeys[tkTLSKind], OTI_DATA_ALLOCATION_FLAGS, (tlsvaluetype)(sizeint)(uCurrentFlags | uFlagsMask));
95 static void DropDataAllocationFlags(EODETLSKIND tkTLSKind, unsigned uFlagsMask)
97 unsigned uCurrentFlags = (unsigned)(sizeint)CThreadLocalStorage::UnsafeGetStorageValue(m_ahtkStorageKeys[tkTLSKind], OTI_DATA_ALLOCATION_FLAGS);
98 CThreadLocalStorage::UnsafeSetStorageValue(m_ahtkStorageKeys[tkTLSKind], OTI_DATA_ALLOCATION_FLAGS, (tlsvaluetype)(sizeint)(uCurrentFlags & ~uFlagsMask));
101 static TrimeshCollidersCache *GetTrimeshCollidersCache(EODETLSKIND tkTLSKind)
103 return (TrimeshCollidersCache *)CThreadLocalStorage::UnsafeGetStorageValue(m_ahtkStorageKeys[tkTLSKind], OTI_TRIMESH_TRIMESH_COLLIDER_CACHE);
106 public:
107 static bool AssignDataAllocationFlags(EODETLSKIND tkTLSKind, unsigned uInitializationFlags);
109 static bool AssignTrimeshCollidersCache(EODETLSKIND tkTLSKind, TrimeshCollidersCache *pccInstance);
110 static void DestroyTrimeshCollidersCache(EODETLSKIND tkTLSKind);
112 private:
113 static void FreeTrimeshCollidersCache(TrimeshCollidersCache *pccCacheInstance);
115 private:
116 static void _OU_CONVENTION_CALLBACK FreeTrimeshCollidersCache_Callback(tlsvaluetype vValueData);
118 private:
119 static HTLSKEY m_ahtkStorageKeys[OTK__MAX];
123 #endif // dTLS_ENABLED
126 #endif // _ODE_ODETLS_H_