Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
a0413bde
Commit
a0413bde
authored
12 years ago
by
Richard Linden
Browse files
Options
Downloads
Patches
Plain Diff
fix for mac thread local storage
parent
a7450935
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/llcommon/llthreadlocalstorage.h
+48
-26
48 additions, 26 deletions
indra/llcommon/llthreadlocalstorage.h
with
48 additions
and
26 deletions
indra/llcommon/llthreadlocalstorage.h
+
48
−
26
View file @
a0413bde
...
...
@@ -152,7 +152,7 @@ class LLThreadLocalSingleton
virtual
~
LLThreadLocalSingleton
()
{
#if LL_DARWIN
//
pthread_setspecific(sInstanceKey, NULL);
pthread_setspecific
(
sInstanceKey
,
NULL
);
#else
sInstance
=
NULL
;
#endif
...
...
@@ -182,17 +182,12 @@ class LLThreadLocalSingleton
setInitState
(
CONSTRUCTING
);
DERIVED_TYPE
*
instancep
=
new
DERIVED_TYPE
();
#if LL_DARWIN
/*static S32 sKeyCreated = pthread_key_create(&sInstanceKey, NULL);
if (sKeyCreated != 0)
{
llerrs << "Could not create thread local storage" << llendl;
}
createTLSInstance
();
S32
result
=
pthread_setspecific
(
sInstanceKey
,
(
void
*
)
instancep
);
if
(
result
!=
0
)
{
llerrs
<<
"Could not set thread local storage"
<<
llendl
;
}
*/
}
#else
sInstance
=
instancep
;
#endif
...
...
@@ -207,7 +202,7 @@ class LLThreadLocalSingleton
static
DERIVED_TYPE
*
getIfExists
()
{
#if LL_DARWIN
return
NULL
;
//
(DERIVED_TYPE*)pthread_getspecific(sInstanceKey);
return
(
DERIVED_TYPE
*
)
pthread_getspecific
(
sInstanceKey
);
#else
return
sInstance
;
#endif
...
...
@@ -235,22 +230,29 @@ class LLThreadLocalSingleton
}
private
:
#if LL_DARWIN
static
EInitState
&
threadLocalInitState
()
static
void
createTLSInitState
()
{
static
S32
key_created
=
pthread_key_create
(
&
sInitStateKey
,
NULL
);
if
(
key_created
!=
0
)
{
llerrs
<<
"Could not create thread local storage"
<<
llendl
;
}
}
static
void
createTLSInstance
()
{
/*
static S32
sKeyC
reated = pthread_key_create(&sIn
itStat
eKey, NULL);
if (
sKeyC
reated != 0)
static
S32
key_c
reated
=
pthread_key_create
(
&
sIn
stanc
eKey
,
NULL
);
if
(
key_c
reated
!=
0
)
{
llerrs
<<
"Could not create thread local storage"
<<
llendl
;
}
return *(EInitState*)pthread_getspecific(sInitStateKey);*/
static
EInitState
state
;
return
state
;
}
#endif
static
EInitState
getInitState
()
{
#if LL_DARWIN
return
threadLocalInitState
();
createTLSInitState
();
return
(
EInitState
)(
int
)
pthread_getspecific
(
sInitStateKey
);
#else
return
sInitState
;
#endif
...
...
@@ -259,7 +261,8 @@ class LLThreadLocalSingleton
static
void
setInitState
(
EInitState
state
)
{
#if LL_DARWIN
threadLocalInitState
()
=
state
;
createTLSInitState
();
pthread_setspecific
(
sInitStateKey
,
(
void
*
)
state
);
#else
sInitState
=
state
;
#endif
...
...
@@ -274,8 +277,8 @@ class LLThreadLocalSingleton
static
__thread
DERIVED_TYPE
*
sInstance
;
static
__thread
EInitState
sInitState
;
#elif LL_DARWIN
//
static pthread_key_t sInstanceKey;
//
static pthread_key_t sInitStateKey;
static
pthread_key_t
sInstanceKey
;
static
pthread_key_t
sInitStateKey
;
#endif
};
...
...
@@ -292,11 +295,12 @@ __thread DERIVED_TYPE* LLThreadLocalSingleton<DERIVED_TYPE>::sInstance = NULL;
template
<
typename
DERIVED_TYPE
>
__thread
typename
LLThreadLocalSingleton
<
DERIVED_TYPE
>::
EInitState
LLThreadLocalSingleton
<
DERIVED_TYPE
>::
sInitState
=
LLThreadLocalSingleton
<
DERIVED_TYPE
>::
UNINITIALIZED
;
#elif LL_DARWIN
/*
template<typename DERIVED_TYPE>
template
<
typename
DERIVED_TYPE
>
pthread_key_t
LLThreadLocalSingleton
<
DERIVED_TYPE
>::
sInstanceKey
;
template
<
typename
DERIVED_TYPE
>
pthread_key_t LLThreadLocalSingleton<DERIVED_TYPE>::sInitStateKey;*/
pthread_key_t
LLThreadLocalSingleton
<
DERIVED_TYPE
>::
sInitStateKey
;
#endif
template
<
typename
DERIVED_TYPE
>
...
...
@@ -305,13 +309,14 @@ class LLThreadLocalSingletonPointer
public:
void
operator
=
(
DERIVED_TYPE
*
value
)
{
sInstance
=
value
;
s
et
Instance
(
value
)
;
}
LL_FORCE_INLINE
static
DERIVED_TYPE
*
getInstance
()
{
#if LL_DARWIN
return
sInstance
.
get
();
createTLSKey
();
return
(
DERIVED_TYPE
*
)
pthread_getspecific
(
sInstanceKey
);
#else
return
sInstance
;
#endif
...
...
@@ -319,7 +324,12 @@ class LLThreadLocalSingletonPointer
LL_FORCE_INLINE
static
void
setInstance
(
DERIVED_TYPE
*
instance
)
{
#if LL_DARWIN
createTLSKey
();
pthread_setspecific
(
sInstanceKey
,
(
void
*
)
instance
);
#else
sInstance
=
instance
;
#endif
}
private
:
...
...
@@ -328,7 +338,19 @@ class LLThreadLocalSingletonPointer
#elif LL_LINUX
static
__thread
DERIVED_TYPE
*
sInstance
;
#elif LL_DARWIN
static
LLThreadLocalPointer
<
DERIVED_TYPE
>
sInstance
;
static
void
TLSError
()
{
llerrs
<<
"Could not create thread local storage"
<<
llendl
;
}
static
void
createTLSKey
()
{
static
S32
key_created
=
pthread_key_create
(
&
sInstanceKey
,
NULL
);
if
(
key_created
!=
0
)
{
llerrs
<<
"Could not create thread local storage"
<<
llendl
;
}
}
static
pthread_key_t
sInstanceKey
;
#endif
};
...
...
@@ -340,7 +362,7 @@ template<typename DERIVED_TYPE>
__thread
DERIVED_TYPE
*
LLThreadLocalSingletonPointer
<
DERIVED_TYPE
>::
sInstance
=
NULL
;
#elif LL_DARWIN
template
<
typename
DERIVED_TYPE
>
LLT
hread
LocalPointer
<
DERIVED_TYPE
>
LLThreadLocalSingletonPointer
<
DERIVED_TYPE
>::
sInstance
;
pt
hread
_key_t
LLThreadLocalSingletonPointer
<
DERIVED_TYPE
>::
sInstance
Key
;
#endif
#endif // LL_LLTHREADLOCALSTORAGE_H
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment