mirror of
https://review.haiku-os.org/haiku
synced 2025-01-31 02:35:03 +01:00
c9fc1d5064
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31143 a95241bf-73f2-0310-859d-f6bbb57e9c96
99 lines
1.4 KiB
C++
99 lines
1.4 KiB
C++
/*
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
|
|
#include "Thread.h"
|
|
|
|
#include "CpuState.h"
|
|
#include "StackTrace.h"
|
|
#include "Team.h"
|
|
|
|
|
|
Thread::Thread(Team* team, thread_id threadID)
|
|
:
|
|
fTeam(team),
|
|
fID(threadID),
|
|
fState(THREAD_STATE_UNKNOWN),
|
|
fCpuState(NULL),
|
|
fStackTrace(NULL)
|
|
{
|
|
}
|
|
|
|
|
|
Thread::~Thread()
|
|
{
|
|
if (fCpuState != NULL)
|
|
fCpuState->RemoveReference();
|
|
if (fStackTrace != NULL)
|
|
fStackTrace->RemoveReference();
|
|
}
|
|
|
|
|
|
status_t
|
|
Thread::Init()
|
|
{
|
|
return B_OK;
|
|
}
|
|
|
|
|
|
void
|
|
Thread::SetName(const BString& name)
|
|
{
|
|
fName = name;
|
|
}
|
|
|
|
|
|
void
|
|
Thread::SetState(uint32 state)
|
|
{
|
|
if (state == fState)
|
|
return;
|
|
|
|
fState = state;
|
|
|
|
// unset CPU state and stack trace, if the thread isn't stopped
|
|
if (fState != THREAD_STATE_STOPPED) {
|
|
SetCpuState(NULL);
|
|
SetStackTrace(NULL);
|
|
}
|
|
|
|
fTeam->NotifyThreadStateChanged(this);
|
|
}
|
|
|
|
|
|
void
|
|
Thread::SetCpuState(CpuState* state)
|
|
{
|
|
if (state == fCpuState)
|
|
return;
|
|
|
|
if (fCpuState != NULL)
|
|
fCpuState->RemoveReference();
|
|
|
|
fCpuState = state;
|
|
|
|
if (fCpuState != NULL)
|
|
fCpuState->AddReference();
|
|
|
|
fTeam->NotifyThreadCpuStateChanged(this);
|
|
}
|
|
|
|
|
|
void
|
|
Thread::SetStackTrace(StackTrace* trace)
|
|
{
|
|
if (trace == fStackTrace)
|
|
return;
|
|
|
|
if (fStackTrace != NULL)
|
|
fStackTrace->RemoveReference();
|
|
|
|
fStackTrace = trace;
|
|
|
|
if (fStackTrace != NULL)
|
|
fStackTrace->AddReference();
|
|
|
|
fTeam->NotifyThreadStackTraceChanged(this);
|
|
}
|