mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
clean up OS resources immediately upon thread exit
Previously, we waited until the next GC to do this, but that can be too long for workloads which create a lot of short-lived threads but don't do much allocation.
This commit is contained in:
parent
44f55673d6
commit
f64d6c857b
@ -45,7 +45,11 @@ void
|
||||
join(Thread* t, Thread* o)
|
||||
{
|
||||
if (t != o) {
|
||||
o->systemThread->join();
|
||||
if (o->state != Thread::ZombieState
|
||||
and o->state != Thread::JoinedState)
|
||||
{
|
||||
o->systemThread->join();
|
||||
}
|
||||
o->state = Thread::JoinedState;
|
||||
}
|
||||
}
|
||||
@ -2281,6 +2285,12 @@ Thread::exit()
|
||||
} else {
|
||||
threadPeer(this, javaThread) = 0;
|
||||
enter(this, Thread::ZombieState);
|
||||
|
||||
lock->dispose();
|
||||
lock = 0;
|
||||
|
||||
systemThread->dispose();
|
||||
systemThread = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2288,7 +2298,9 @@ Thread::exit()
|
||||
void
|
||||
Thread::dispose()
|
||||
{
|
||||
lock->dispose();
|
||||
if (lock) {
|
||||
lock->dispose();
|
||||
}
|
||||
|
||||
if (systemThread) {
|
||||
systemThread->dispose();
|
||||
|
@ -2746,7 +2746,11 @@ notifyAll(Thread* t, object o)
|
||||
inline void
|
||||
interrupt(Thread*, Thread* target)
|
||||
{
|
||||
target->systemThread->interrupt();
|
||||
if (target->state != Thread::ZombieState
|
||||
and target->state != Thread::JoinedState)
|
||||
{
|
||||
target->systemThread->interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
|
Loading…
Reference in New Issue
Block a user