1120cfc62SIngo Weinhold /* 2*5fc675d5SIngo Weinhold * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. 3120cfc62SIngo Weinhold * Distributed under the terms of the MIT License. 4120cfc62SIngo Weinhold */ 5120cfc62SIngo Weinhold #ifndef THREAD_H 6120cfc62SIngo Weinhold #define THREAD_H 7120cfc62SIngo Weinhold 8a39c92c2SIngo Weinhold 91b9d2885SIngo Weinhold #include <String.h> 101b9d2885SIngo Weinhold 11120cfc62SIngo Weinhold #include <util/DoublyLinkedList.h> 12120cfc62SIngo Weinhold 13*5fc675d5SIngo Weinhold #include "ProfiledEntity.h" 14*5fc675d5SIngo Weinhold #include "ProfileResult.h" 15120cfc62SIngo Weinhold 16120cfc62SIngo Weinhold 17120cfc62SIngo Weinhold class Team; 18120cfc62SIngo Weinhold 19120cfc62SIngo Weinhold 20*5fc675d5SIngo Weinhold class Thread : public ProfiledEntity, public DoublyLinkedListLinkImpl<Thread> { 21120cfc62SIngo Weinhold public: 221b9d2885SIngo Weinhold Thread(thread_id threadID, const char* name, 231b9d2885SIngo Weinhold Team* team); 24*5fc675d5SIngo Weinhold virtual ~Thread(); 25120cfc62SIngo Weinhold 26120cfc62SIngo Weinhold inline thread_id ID() const; 27120cfc62SIngo Weinhold inline const char* Name() const; 28120cfc62SIngo Weinhold inline addr_t* Samples() const; 29120cfc62SIngo Weinhold inline Team* GetTeam() const; 30120cfc62SIngo Weinhold 31*5fc675d5SIngo Weinhold virtual int32 EntityID() const; 32*5fc675d5SIngo Weinhold virtual const char* EntityName() const; 33*5fc675d5SIngo Weinhold virtual const char* EntityType() const; 34*5fc675d5SIngo Weinhold 35*5fc675d5SIngo Weinhold inline ProfileResult* GetProfileResult() const; 36*5fc675d5SIngo Weinhold void SetProfileResult(ProfileResult* result); 37ed2fc873SIngo Weinhold 381b9d2885SIngo Weinhold void UpdateInfo(const char* name); 39120cfc62SIngo Weinhold 40120cfc62SIngo Weinhold void SetSampleArea(area_id area, addr_t* samples); 41120cfc62SIngo Weinhold void SetInterval(bigtime_t interval); 42120cfc62SIngo Weinhold 430f379156SIngo Weinhold inline status_t AddImage(Image* image); 440f379156SIngo Weinhold inline void RemoveImage(Image* image); 45120cfc62SIngo Weinhold 46120cfc62SIngo Weinhold void AddSamples(int32 count, int32 dropped, 47120cfc62SIngo Weinhold int32 stackDepth, bool variableStackDepth, 48120cfc62SIngo Weinhold int32 event); 490f379156SIngo Weinhold void AddSamples(addr_t* samples, int32 sampleCount); 50120cfc62SIngo Weinhold void PrintResults() const; 51120cfc62SIngo Weinhold 52120cfc62SIngo Weinhold private: 531b9d2885SIngo Weinhold thread_id fID; 541b9d2885SIngo Weinhold BString fName; 55120cfc62SIngo Weinhold ::Team* fTeam; 56120cfc62SIngo Weinhold area_id fSampleArea; 57120cfc62SIngo Weinhold addr_t* fSamples; 58*5fc675d5SIngo Weinhold ProfileResult* fProfileResult; 59ed2fc873SIngo Weinhold }; 60ed2fc873SIngo Weinhold 61ed2fc873SIngo Weinhold 62120cfc62SIngo Weinhold thread_id 63120cfc62SIngo Weinhold Thread::ID() const 64120cfc62SIngo Weinhold { 651b9d2885SIngo Weinhold return fID; 66120cfc62SIngo Weinhold } 67120cfc62SIngo Weinhold 68120cfc62SIngo Weinhold 69120cfc62SIngo Weinhold const char* 70120cfc62SIngo Weinhold Thread::Name() const 71120cfc62SIngo Weinhold { 721b9d2885SIngo Weinhold return fName.String(); 73120cfc62SIngo Weinhold } 74120cfc62SIngo Weinhold 75120cfc62SIngo Weinhold 76120cfc62SIngo Weinhold addr_t* 77120cfc62SIngo Weinhold Thread::Samples() const 78120cfc62SIngo Weinhold { 79120cfc62SIngo Weinhold return fSamples; 80120cfc62SIngo Weinhold } 81120cfc62SIngo Weinhold 82120cfc62SIngo Weinhold 83120cfc62SIngo Weinhold Team* 84120cfc62SIngo Weinhold Thread::GetTeam() const 85120cfc62SIngo Weinhold { 86120cfc62SIngo Weinhold return fTeam; 87120cfc62SIngo Weinhold } 88120cfc62SIngo Weinhold 89120cfc62SIngo Weinhold 90*5fc675d5SIngo Weinhold ProfileResult* 91*5fc675d5SIngo Weinhold Thread::GetProfileResult() const 92ed2fc873SIngo Weinhold { 93ed2fc873SIngo Weinhold return fProfileResult; 94ed2fc873SIngo Weinhold } 95ed2fc873SIngo Weinhold 96ed2fc873SIngo Weinhold 970f379156SIngo Weinhold status_t 980f379156SIngo Weinhold Thread::AddImage(Image* image) 990f379156SIngo Weinhold { 1000f379156SIngo Weinhold return fProfileResult->AddImage(image); 1010f379156SIngo Weinhold } 1020f379156SIngo Weinhold 1030f379156SIngo Weinhold 1040f379156SIngo Weinhold void 1050f379156SIngo Weinhold Thread::RemoveImage(Image* image) 1060f379156SIngo Weinhold { 1070f379156SIngo Weinhold fProfileResult->RemoveImage(image); 1080f379156SIngo Weinhold } 1090f379156SIngo Weinhold 1100f379156SIngo Weinhold 111120cfc62SIngo Weinhold #endif // THREAD_H 112