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
36aa62d7
Commit
36aa62d7
authored
4 years ago
by
Rye Mutt
Browse files
Options
Downloads
Patches
Plain Diff
Replace LLMutex with absl::Mutex initialized as constexpr in LLError
parent
30db82df
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/llcommon/llerror.cpp
+30
-18
30 additions, 18 deletions
indra/llcommon/llerror.cpp
with
30 additions
and
18 deletions
indra/llcommon/llerror.cpp
+
30
−
18
View file @
36aa62d7
...
...
@@ -46,8 +46,10 @@
#include
<vector>
#include
<string_view>
#include
"string.h"
#include
<absl/container/flat_hash_map.h>
#include
<absl/strings/str_format.h>
#include
"absl/synchronization/mutex.h"
#include
"absl/container/flat_hash_map.h"
#include
"absl/strings/str_format.h"
#include
"llapp.h"
#include
"llapr.h"
...
...
@@ -1276,16 +1278,26 @@ namespace {
LOG_MUTEX
,
STACKS_MUTEX
};
// Some logging calls happen very early in processing -- so early that our
// module-static variables aren't yet initialized. getMutex() wraps a
// function-static LLMutex so that early calls can still have a valid
// LLMutex instance.
ABSL_CONST_INIT
absl
::
Mutex
sLogMutex
(
absl
::
kConstInit
);
ABSL_CONST_INIT
absl
::
Mutex
sStackMutex
(
absl
::
kConstInit
);
template
<
MutexDiscriminator
MTX
>
LLMutex
*
getMutex
()
absl
::
Mutex
*
getMutex
()
{
return
nullptr
;
}
template
<
>
absl
::
Mutex
*
getMutex
<
LOG_MUTEX
>
()
{
return
&
sLogMutex
;
}
template
<
>
absl
::
Mutex
*
getMutex
<
STACKS_MUTEX
>
()
{
// guaranteed to be initialized the first time control reaches here
static
LLMutex
sMutex
;
return
&
sMutex
;
return
&
sStackMutex
;
}
bool
checkLevelMap
(
const
LevelMap
&
map
,
const
std
::
string
&
key
,
...
...
@@ -1334,7 +1346,7 @@ namespace LLError
bool
Log
::
shouldLog
(
CallSite
&
site
)
{
LL
MutexTrylock
lock
(
getMutex
<
LOG_MUTEX
>
(),
5
);
Absl
Mutex
Maybe
Trylock
lock
(
getMutex
<
LOG_MUTEX
>
(),
5
);
if
(
!
lock
.
isLocked
())
{
return
false
;
...
...
@@ -1377,7 +1389,7 @@ namespace LLError
std
::
ostringstream
*
Log
::
out
()
{
LL
MutexTrylock
lock
(
getMutex
<
LOG_MUTEX
>
(),
5
);
Absl
Mutex
Maybe
Trylock
lock
(
getMutex
<
LOG_MUTEX
>
(),
5
);
if
(
lock
.
isLocked
())
{
...
...
@@ -1395,7 +1407,7 @@ namespace LLError
void
Log
::
flush
(
std
::
ostringstream
*
out
,
char
*
message
)
{
LL
MutexTrylock
lock
(
getMutex
<
LOG_MUTEX
>
(),
5
);
Absl
Mutex
Maybe
Trylock
lock
(
getMutex
<
LOG_MUTEX
>
(),
5
);
if
(
!
lock
.
isLocked
())
{
return
;
...
...
@@ -1427,7 +1439,7 @@ namespace LLError
void
Log
::
flush
(
std
::
ostringstream
*
out
,
const
CallSite
&
site
)
{
LL
MutexTrylock
lock
(
getMutex
<
LOG_MUTEX
>
(),
5
);
Absl
Mutex
Maybe
Trylock
lock
(
getMutex
<
LOG_MUTEX
>
(),
5
);
if
(
!
lock
.
isLocked
())
{
return
;
...
...
@@ -1616,7 +1628,7 @@ namespace LLError
//static
void
LLCallStacks
::
push
(
const
char
*
function
,
const
int
line
)
{
LLMutex
Trylock
lock
(
getMutex
<
STACKS_MUTEX
>
(),
5
);
AbslMutexMaybe
Trylock
lock
(
getMutex
<
STACKS_MUTEX
>
(),
5
);
if
(
!
lock
.
isLocked
())
{
return
;
...
...
@@ -1650,7 +1662,7 @@ namespace LLError
//static
void
LLCallStacks
::
end
(
std
::
ostringstream
*
_out
)
{
LLMutex
Trylock
lock
(
getMutex
<
STACKS_MUTEX
>
(),
5
);
AbslMutexMaybe
Trylock
lock
(
getMutex
<
STACKS_MUTEX
>
(),
5
);
if
(
!
lock
.
isLocked
())
{
return
;
...
...
@@ -1672,7 +1684,7 @@ namespace LLError
//static
void
LLCallStacks
::
print
()
{
LLMutex
Trylock
lock
(
getMutex
<
STACKS_MUTEX
>
(),
5
);
AbslMutexMaybe
Trylock
lock
(
getMutex
<
STACKS_MUTEX
>
(),
5
);
if
(
!
lock
.
isLocked
())
{
return
;
...
...
@@ -1715,7 +1727,7 @@ namespace LLError
bool
debugLoggingEnabled
(
const
std
::
string
&
tag
)
{
LLMutex
Trylock
lock
(
getMutex
<
LOG_MUTEX
>
(),
5
);
AbslMutexMaybe
Trylock
lock
(
getMutex
<
LOG_MUTEX
>
(),
5
);
if
(
!
lock
.
isLocked
())
{
return
false
;
...
...
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