Added base time, last event time, and data source name to the model.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30411 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-04-25 20:50:37 +00:00
parent 602a9fe54d
commit 31391fed6b
3 changed files with 72 additions and 7 deletions
+18 -1
View File
@@ -259,10 +259,13 @@ Model::Thread::AddThreadWaitObject(WaitObject* waitObject,
// #pragma mark - Model
Model::Model(void* eventData, size_t eventDataSize)
Model::Model(const char* dataSourceName, void* eventData, size_t eventDataSize)
:
fDataSourceName(dataSourceName),
fEventData(eventData),
fEventDataSize(eventDataSize),
fBaseTime(0),
fLastEventTime(0),
fTeams(20, true),
fThreads(20, true),
fWaitObjectGroups(20, true)
@@ -276,6 +279,20 @@ Model::~Model()
}
void
Model::SetBaseTime(bigtime_t time)
{
fBaseTime = time;
}
void
Model::SetLastEventTime(bigtime_t time)
{
fLastEventTime = time;
}
int32
Model::CountTeams() const
{
+39 -2
View File
@@ -5,9 +5,10 @@
#ifndef MODEL_H
#define MODEL_H
#include <ObjectList.h>
#include <OS.h>
#include <String.h>
#include <ObjectList.h>
#include <Referenceable.h>
#include <system_profiler_defs.h>
@@ -26,9 +27,18 @@ public:
class Thread;
public:
Model(void* eventData, size_t eventDataSize);
Model(const char* dataSourceName,
void* eventData, size_t eventDataSize);
~Model();
inline const char* DataSourceName() const;
inline bigtime_t BaseTime() const;
void SetBaseTime(bigtime_t time);
inline bigtime_t LastEventTime() const;
void SetLastEventTime(bigtime_t time);
int32 CountTeams() const;
Team* TeamAt(int32 index) const;
Team* TeamByID(team_id id) const;
@@ -64,8 +74,11 @@ private:
typedef BObjectList<WaitObjectGroup> WaitObjectGroupList;
private:
BString fDataSourceName;
void* fEventData;
size_t fEventDataSize;
bigtime_t fBaseTime;
bigtime_t fLastEventTime;
TeamList fTeams; // sorted by ID
ThreadList fThreads; // sorted by ID
WaitObjectGroupList fWaitObjectGroups;
@@ -295,6 +308,30 @@ private:
};
// #pragma mark - Model
const char*
Model::DataSourceName() const
{
return fDataSourceName.String();
}
bigtime_t
Model::BaseTime() const
{
return fBaseTime;
}
bigtime_t
Model::LastEventTime() const
{
return fLastEventTime;
}
// #pragma mark - WaitObject
@@ -58,8 +58,10 @@ ModelLoader::ThreadInfo::ThreadInfo(Model::Thread* thread)
inline void
ModelLoader::_UpdateLastEventTime(bigtime_t time)
{
if (fBaseTime < 0)
if (fBaseTime < 0) {
fBaseTime = time;
fModel->SetBaseTime(time);
}
fLastEventTime = time - fBaseTime;
}
@@ -168,7 +170,7 @@ ModelLoader::_Loader()
} catch(...) {
error = B_ERROR;
}
// clean up and notify the target
AutoLocker<BLocker> locker(fLock);
@@ -210,8 +212,13 @@ ModelLoader::_Load()
if (error != B_OK)
return error;
// get the data source name
BString dataSourceName;
fDataSource->GetName(dataSourceName);
// create a model
fModel = new(std::nothrow) Model(eventData, eventDataSize);
fModel = new(std::nothrow) Model(dataSourceName.String(), eventData,
eventDataSize);
if (fModel == NULL) {
free(eventData);
return B_NO_MEMORY;
@@ -247,7 +254,7 @@ ModelLoader::_Load()
if (bufferSize < 0)
return bufferSize;
if (buffer == NULL)
return B_OK;
break;
// process the event
status_t error = _ProcessEvent(event, cpu, buffer, bufferSize);
@@ -261,6 +268,10 @@ ModelLoader::_Load()
return B_ERROR;
}
}
fModel->SetLastEventTime(fLastEventTime);
return B_OK;
}