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
7a09a539
Commit
7a09a539
authored
5 years ago
by
Nat Goodspeed
Browse files
Options
Downloads
Patches
Plain Diff
DRTVWR-494: Add on_main_thread(), sibling to assert_main_thread().
parent
b22f89c9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
indra/llcommon/llthread.cpp
+24
-4
24 additions, 4 deletions
indra/llcommon/llthread.cpp
indra/llcommon/llthread.h
+1
-2
1 addition, 2 deletions
indra/llcommon/llthread.h
with
25 additions
and
6 deletions
indra/llcommon/llthread.cpp
+
24
−
4
View file @
7a09a539
...
@@ -97,14 +97,34 @@ U32 LL_THREAD_LOCAL sThreadID = 0;
...
@@ -97,14 +97,34 @@ U32 LL_THREAD_LOCAL sThreadID = 0;
U32
LLThread
::
sIDIter
=
0
;
U32
LLThread
::
sIDIter
=
0
;
namespace
{
U32
main_thread
()
{
// Using a function-static variable to identify the main thread
// requires that control reach here from the main thread before it
// reaches here from any other thread. We simply trust that whichever
// thread gets here first is the main thread.
static
U32
s_thread_id
=
LLThread
::
currentID
();
return
s_thread_id
;
}
}
// anonymous namespace
LL_COMMON_API
bool
on_main_thread
()
{
return
(
LLThread
::
currentID
()
==
main_thread
());
}
LL_COMMON_API
void
assert_main_thread
()
LL_COMMON_API
void
assert_main_thread
()
{
{
static
U32
s_thread_id
=
LLThread
::
currentID
();
auto
curr
=
LLThread
::
currentID
();
if
(
LLThread
::
currentID
()
!=
s_thread_id
)
auto
main
=
main_thread
();
if
(
curr
!=
main
)
{
{
LL_WARNS
()
<<
"Illegal execution from thread id "
<<
(
S32
)
LLThread
::
currentID
()
LL_WARNS
()
<<
"Illegal execution from thread id "
<<
curr
<<
" outside main thread "
<<
(
S32
)
s_thread_id
<<
LL_ENDL
;
<<
" outside main thread "
<<
main
<<
LL_ENDL
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
indra/llcommon/llthread.h
+
1
−
2
View file @
7a09a539
...
@@ -34,8 +34,6 @@
...
@@ -34,8 +34,6 @@
#include
"llrefcount.h"
#include
"llrefcount.h"
#include
<thread>
#include
<thread>
LL_COMMON_API
void
assert_main_thread
();
namespace
LLTrace
namespace
LLTrace
{
{
class
ThreadRecorder
;
class
ThreadRecorder
;
...
@@ -168,5 +166,6 @@ class LL_COMMON_API LLResponder : public LLThreadSafeRefCount
...
@@ -168,5 +166,6 @@ class LL_COMMON_API LLResponder : public LLThreadSafeRefCount
//============================================================================
//============================================================================
extern
LL_COMMON_API
void
assert_main_thread
();
extern
LL_COMMON_API
void
assert_main_thread
();
extern
LL_COMMON_API
bool
on_main_thread
();
#endif // LL_LLTHREAD_H
#endif // LL_LLTHREAD_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