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
a7450935
Commit
a7450935
authored
12 years ago
by
Richard Linden
Browse files
Options
Downloads
Patches
Plain Diff
Attempted fix for thread local storage on OS X
parent
91a8383b
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
+44
-14
44 additions, 14 deletions
indra/llcommon/llthreadlocalstorage.h
with
44 additions
and
14 deletions
indra/llcommon/llthreadlocalstorage.h
+
44
−
14
View file @
a7450935
...
@@ -151,15 +151,17 @@ class LLThreadLocalSingleton
...
@@ -151,15 +151,17 @@ class LLThreadLocalSingleton
virtual
~
LLThreadLocalSingleton
()
virtual
~
LLThreadLocalSingleton
()
{
{
sInstance
=
NULL
;
#if LL_DARWIN
//pthread_setspecific(sInstanceKey, NULL);
#else
sInstance
=
NULL
;
#endif
setInitState
(
DELETED
);
setInitState
(
DELETED
);
}
}
static
void
deleteSingleton
()
static
void
deleteSingleton
()
{
{
delete
sInstance
;
delete
getIfExists
();
sInstance
=
NULL
;
setInitState
(
DELETED
);
}
}
static
DERIVED_TYPE
*
getInstance
()
static
DERIVED_TYPE
*
getInstance
()
...
@@ -178,9 +180,24 @@ class LLThreadLocalSingleton
...
@@ -178,9 +180,24 @@ class LLThreadLocalSingleton
if
(
!
getIfExists
())
if
(
!
getIfExists
())
{
{
setInitState
(
CONSTRUCTING
);
setInitState
(
CONSTRUCTING
);
sInstance
=
new
DERIVED_TYPE
();
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;
}
S32 result = pthread_setspecific(sInstanceKey, (void*)instancep);
if (result != 0)
{
llerrs << "Could not set thread local storage" << llendl;
}*/
#else
sInstance
=
instancep
;
#endif
setInitState
(
INITIALIZING
);
setInitState
(
INITIALIZING
);
sI
nstance
->
initSingleton
();
i
nstance
p
->
initSingleton
();
setInitState
(
INITIALIZED
);
setInitState
(
INITIALIZED
);
}
}
...
@@ -190,7 +207,7 @@ class LLThreadLocalSingleton
...
@@ -190,7 +207,7 @@ class LLThreadLocalSingleton
static
DERIVED_TYPE
*
getIfExists
()
static
DERIVED_TYPE
*
getIfExists
()
{
{
#if LL_DARWIN
#if LL_DARWIN
return
sInstance
.
get
(
);
return
NULL
;
//(DERIVED_TYPE*)pthread_getspecific(
sInstance
Key
);
#else
#else
return
sInstance
;
return
sInstance
;
#endif
#endif
...
@@ -217,10 +234,23 @@ class LLThreadLocalSingleton
...
@@ -217,10 +234,23 @@ class LLThreadLocalSingleton
return
getInitState
()
==
DELETED
;
return
getInitState
()
==
DELETED
;
}
}
private
:
private
:
#if LL_DARWIN
static
EInitState
&
threadLocalInitState
()
{
/*static S32 sKeyCreated = pthread_key_create(&sInitStateKey, NULL);
if (sKeyCreated != 0)
{
llerrs << "Could not create thread local storage" << llendl;
}
return *(EInitState*)pthread_getspecific(sInitStateKey);*/
static
EInitState
state
;
return
state
;
}
#endif
static
EInitState
getInitState
()
static
EInitState
getInitState
()
{
{
#if LL_DARWIN
#if LL_DARWIN
return
(
EInitState
)(
int
)
s
InitState
.
get
();
return
threadLocal
InitState
();
#else
#else
return
sInitState
;
return
sInitState
;
#endif
#endif
...
@@ -229,7 +259,7 @@ class LLThreadLocalSingleton
...
@@ -229,7 +259,7 @@ class LLThreadLocalSingleton
static
void
setInitState
(
EInitState
state
)
static
void
setInitState
(
EInitState
state
)
{
{
#if LL_DARWIN
#if LL_DARWIN
s
InitState
=
(
int
*
)
state
;
threadLocal
InitState
()
=
state
;
#else
#else
sInitState
=
state
;
sInitState
=
state
;
#endif
#endif
...
@@ -244,8 +274,8 @@ class LLThreadLocalSingleton
...
@@ -244,8 +274,8 @@ class LLThreadLocalSingleton
static
__thread
DERIVED_TYPE
*
sInstance
;
static
__thread
DERIVED_TYPE
*
sInstance
;
static
__thread
EInitState
sInitState
;
static
__thread
EInitState
sInitState
;
#elif LL_DARWIN
#elif LL_DARWIN
static
LLT
hread
LocalPointer
<
DERIVED_TYPE
>
sInstance
;
//
static
pt
hread
_key_t
sInstance
Key
;
static
LLT
hread
LocalPointer
<
int
>
sInitState
;
//
static
pt
hread
_key_t
sInitState
Key
;
#endif
#endif
};
};
...
@@ -262,11 +292,11 @@ __thread DERIVED_TYPE* LLThreadLocalSingleton<DERIVED_TYPE>::sInstance = NULL;
...
@@ -262,11 +292,11 @@ __thread DERIVED_TYPE* LLThreadLocalSingleton<DERIVED_TYPE>::sInstance = NULL;
template
<
typename
DERIVED_TYPE
>
template
<
typename
DERIVED_TYPE
>
__thread
typename
LLThreadLocalSingleton
<
DERIVED_TYPE
>::
EInitState
LLThreadLocalSingleton
<
DERIVED_TYPE
>::
sInitState
=
LLThreadLocalSingleton
<
DERIVED_TYPE
>::
UNINITIALIZED
;
__thread
typename
LLThreadLocalSingleton
<
DERIVED_TYPE
>::
EInitState
LLThreadLocalSingleton
<
DERIVED_TYPE
>::
sInitState
=
LLThreadLocalSingleton
<
DERIVED_TYPE
>::
UNINITIALIZED
;
#elif LL_DARWIN
#elif LL_DARWIN
template
<
typename
DERIVED_TYPE
>
/*
template<typename DERIVED_TYPE>
LLT
hread
LocalPointer
<
DERIVED_TYPE
>
LLThreadLocalSingleton
<
DERIVED_TYPE
>::
sInstance
;
pt
hread
_key_t
LLThreadLocalSingleton<DERIVED_TYPE>::sInstance
Key
;
template<typename DERIVED_TYPE>
template<typename DERIVED_TYPE>
LLT
hread
LocalPointer
<
int
>
LLThreadLocalSingleton
<
DERIVED_TYPE
>::
sInitState
;
pt
hread
_key_t
LLThreadLocalSingleton<DERIVED_TYPE>::sInitState
Key;*/
#endif
#endif
template
<
typename
DERIVED_TYPE
>
template
<
typename
DERIVED_TYPE
>
...
...
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