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
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
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 Archive
Alchemy Viewer
Commits
30637331
Commit
30637331
authored
7 years ago
by
Drake Arconis
Browse files
Options
Downloads
Patches
Plain Diff
Some changes from viewer64
parent
9ad0f677
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
indra/llcommon/llmemory.cpp
+10
-10
10 additions, 10 deletions
indra/llcommon/llmemory.cpp
indra/llcommon/llthread.cpp
+149
-101
149 additions, 101 deletions
indra/llcommon/llthread.cpp
indra/llcommon/llthread.h
+69
-67
69 additions, 67 deletions
indra/llcommon/llthread.h
with
228 additions
and
178 deletions
indra/llcommon/llmemory.cpp
+
10
−
10
View file @
30637331
...
@@ -234,6 +234,7 @@ U32Kilobytes LLMemory::getAllocatedMemKB()
...
@@ -234,6 +234,7 @@ U32Kilobytes LLMemory::getAllocatedMemKB()
#if defined(LL_WINDOWS)
#if defined(LL_WINDOWS)
//static
U64
LLMemory
::
getCurrentRSS
()
U64
LLMemory
::
getCurrentRSS
()
{
{
PROCESS_MEMORY_COUNTERS
counters
;
PROCESS_MEMORY_COUNTERS
counters
;
...
@@ -264,12 +265,11 @@ U64 LLMemory::getCurrentRSS()
...
@@ -264,12 +265,11 @@ U64 LLMemory::getCurrentRSS()
mach_msg_type_number_t
basicInfoCount
=
MACH_TASK_BASIC_INFO_COUNT
;
mach_msg_type_number_t
basicInfoCount
=
MACH_TASK_BASIC_INFO_COUNT
;
if
(
task_info
(
mach_task_self
(),
MACH_TASK_BASIC_INFO
,
(
task_info_t
)
&
basicInfo
,
&
basicInfoCount
)
==
KERN_SUCCESS
)
if
(
task_info
(
mach_task_self
(),
MACH_TASK_BASIC_INFO
,
(
task_info_t
)
&
basicInfo
,
&
basicInfoCount
)
==
KERN_SUCCESS
)
{
{
residentSize
=
basicInfo
.
resident_size
;
// residentSize = basicInfo.resident_size;
// Although this method is defined to return the "resident set size,"
// If we ever wanted it, the process virtual size is also available as:
// in fact what callers want from it is the total virtual memory
// virtualSize = basicInfo.virtual_size;
// consumed by the application.
residentSize
=
basicInfo
.
virtual_size
;
// LL_INFOS() << "resident size is " << residentSize << LL_ENDL;
}
}
else
else
{
{
...
...
This diff is collapsed.
Click to expand it.
indra/llcommon/llthread.cpp
+
149
−
101
View file @
30637331
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include
"lltimer.h"
#include
"lltimer.h"
#include
"lltrace.h"
#include
"lltrace.h"
#include
"lltracethreadrecorder.h"
#include
"lltracethreadrecorder.h"
#include
"llexception.h"
#include
<chrono>
#include
<chrono>
...
@@ -109,17 +110,53 @@ void LLThread::runWrapper()
...
@@ -109,17 +110,53 @@ void LLThread::runWrapper()
// for now, hard code all LLThreads to report to single master thread recorder, which is known to be running on main thread
// for now, hard code all LLThreads to report to single master thread recorder, which is known to be running on main thread
mRecorder
=
std
::
make_unique
<
LLTrace
::
ThreadRecorder
>
(
*
LLTrace
::
get_master_thread_recorder
());
mRecorder
=
std
::
make_unique
<
LLTrace
::
ThreadRecorder
>
(
*
LLTrace
::
get_master_thread_recorder
());
try
{
// Run the user supplied function
// Run the user supplied function
do
{
try
{
run
();
run
();
}
catch
(
const
LLContinueError
&
e
)
{
LL_WARNS
(
"THREAD"
)
<<
"ContinueException on thread '"
<<
mName
<<
"' reentering run(). Error what is: '"
<<
e
.
what
()
<<
"'"
<<
LL_ENDL
;
//output possible call stacks to log file.
LLError
::
LLCallStacks
::
print
();
//LL_INFOS() << "LLThread::staticRun() Exiting: " << threadp->mName << LL_ENDL;
LOG_UNHANDLED_EXCEPTION
(
"LLThread"
);
continue
;
}
break
;
mRecorder
.
reset
(
nullptr
);
}
while
(
true
);
//LL_INFOS() << "LLThread::staticRun() Exiting: " << mName << LL_ENDL;
// We're done with the run function, this thread is done executing now.
// We're done with the run function, this thread is done executing now.
//NB: we are using this flag to sync across threads...we really need memory barriers here
//NB: we are using this flag to sync across threads...we really need memory barriers here
mStatus
=
STOPPED
;
mStatus
=
STOPPED
;
}
}
catch
(
const
std
::
bad_alloc
&
)
{
mStatus
=
CRASHED
;
LLMemory
::
logMemoryInfo
(
TRUE
);
//output possible call stacks to log file.
LLError
::
LLCallStacks
::
print
();
LL_ERRS
(
"THREAD"
)
<<
"Bad memory allocation in LLThread::staticRun() named '"
<<
mName
<<
"'!"
<<
LL_ENDL
;
}
catch
(...)
{
mStatus
=
CRASHED
;
CRASH_ON_UNHANDLED_EXCEPTION
(
"LLThread"
);
}
mRecorder
.
reset
(
nullptr
);
}
LLThread
::
LLThread
(
const
std
::
string
&
name
,
apr_pool_t
*
poolp
)
:
LLThread
::
LLThread
(
const
std
::
string
&
name
,
apr_pool_t
*
poolp
)
:
mPaused
(
FALSE
),
mPaused
(
FALSE
),
...
@@ -128,6 +165,8 @@ LLThread::LLThread(const std::string& name, apr_pool_t *poolp) :
...
@@ -128,6 +165,8 @@ LLThread::LLThread(const std::string& name, apr_pool_t *poolp) :
mDataLock
(
std
::
make_unique
<
LLMutex
>
()),
mDataLock
(
std
::
make_unique
<
LLMutex
>
()),
mStatus
(
STOPPED
)
mStatus
(
STOPPED
)
{
{
// Thread creation probably CAN be paranoid about APR being initialized, if necessary
// Thread creation probably CAN be paranoid about APR being initialized, if necessary
if
(
poolp
)
if
(
poolp
)
{
{
...
@@ -147,6 +186,11 @@ LLThread::~LLThread()
...
@@ -147,6 +186,11 @@ LLThread::~LLThread()
{
{
shutdown
();
shutdown
();
if
(
isCrashed
())
{
LL_WARNS
(
"THREAD"
)
<<
"Destroying crashed thread named '"
<<
mName
<<
"'"
<<
LL_ENDL
;
}
if
(
mLocalAPRFilePoolp
)
if
(
mLocalAPRFilePoolp
)
{
{
delete
mLocalAPRFilePoolp
;
delete
mLocalAPRFilePoolp
;
...
@@ -156,6 +200,10 @@ LLThread::~LLThread()
...
@@ -156,6 +200,10 @@ LLThread::~LLThread()
void
LLThread
::
shutdown
()
void
LLThread
::
shutdown
()
{
{
if
(
isCrashed
())
{
LL_WARNS
(
"THREAD"
)
<<
"Shutting down crashed thread named '"
<<
mName
<<
"'"
<<
LL_ENDL
;
}
// Warning! If you somehow call the thread destructor from itself,
// Warning! If you somehow call the thread destructor from itself,
// the thread will die in an unclean fashion!
// the thread will die in an unclean fashion!
if
(
!
isStopped
())
if
(
!
isStopped
())
...
@@ -245,7 +293,7 @@ void LLThread::start()
...
@@ -245,7 +293,7 @@ void LLThread::start()
}
}
catch
(
const
boost
::
thread_resource_error
&
err
)
catch
(
const
boost
::
thread_resource_error
&
err
)
{
{
mStatus
=
STOPP
ED
;
mStatus
=
CRASH
ED
;
LL_WARNS
()
<<
"Failed to start thread:
\"
"
<<
mName
<<
"
\"
due to error: "
<<
err
.
what
()
<<
LL_ENDL
;
LL_WARNS
()
<<
"Failed to start thread:
\"
"
<<
mName
<<
"
\"
due to error: "
<<
err
.
what
()
<<
LL_ENDL
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
indra/llcommon/llthread.h
+
69
−
67
View file @
30637331
...
@@ -52,15 +52,17 @@ public:
...
@@ -52,15 +52,17 @@ public:
{
{
STOPPED
=
0
,
// The thread is not running. Not started, or has exited its run function
STOPPED
=
0
,
// The thread is not running. Not started, or has exited its run function
RUNNING
=
1
,
// The thread is currently running
RUNNING
=
1
,
// The thread is currently running
QUITTING
=
2
// Someone wants this thread to quit
QUITTING
=
2
,
// Someone wants this thread to quit
CRASHED
=
-
1
// An uncaught exception was thrown by the thread
}
EThreadStatus
;
}
EThreadStatus
;
LLThread
(
const
std
::
string
&
name
,
apr_pool_t
*
poolp
=
nullptr
);
LLThread
(
const
std
::
string
&
name
,
apr_pool_t
*
poolp
=
NULL
);
virtual
~
LLThread
();
// Warning! You almost NEVER want to destroy a thread unless it's in the STOPPED state.
virtual
~
LLThread
();
// Warning! You almost NEVER want to destroy a thread unless it's in the STOPPED state.
virtual
void
shutdown
();
// stops the thread
virtual
void
shutdown
();
// stops the thread
bool
isQuitting
()
const
{
return
(
QUITTING
==
mStatus
);
}
bool
isQuitting
()
const
{
return
(
QUITTING
==
mStatus
);
}
bool
isStopped
()
const
{
return
(
STOPPED
==
mStatus
);
}
bool
isStopped
()
const
{
return
(
STOPPED
==
mStatus
)
||
(
CRASHED
==
mStatus
);
}
bool
isCrashed
()
const
{
return
(
CRASHED
==
mStatus
);
}
static
boost
::
thread
::
id
currentID
();
// Return ID of current thread
static
boost
::
thread
::
id
currentID
();
// Return ID of current thread
static
void
yield
();
// Static because it can be called by the main thread, which doesn't have an LLThread data structure.
static
void
yield
();
// Static because it can be called by the main thread, which doesn't have an LLThread data structure.
...
...
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