2009-06-16 04:25:36 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef THREAD_H
|
|
|
|
#define THREAD_H
|
|
|
|
|
|
|
|
#include <OS.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
2009-06-17 01:47:49 +04:00
|
|
|
#include <Referenceable.h>
|
2009-06-16 04:25:36 +04:00
|
|
|
#include <util/DoublyLinkedList.h>
|
|
|
|
|
|
|
|
|
2009-06-18 04:35:12 +04:00
|
|
|
class Team;
|
|
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
THREAD_STATE_UNKNOWN,
|
|
|
|
THREAD_STATE_RUNNING,
|
|
|
|
THREAD_STATE_STOPPED
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-06-17 01:47:49 +04:00
|
|
|
class Thread : public Referenceable, public DoublyLinkedListLinkImpl<Thread> {
|
2009-06-16 04:25:36 +04:00
|
|
|
public:
|
2009-06-18 04:35:12 +04:00
|
|
|
Thread(Team* team, thread_id threadID);
|
2009-06-16 04:25:36 +04:00
|
|
|
~Thread();
|
|
|
|
|
|
|
|
status_t Init();
|
|
|
|
|
2009-06-18 04:35:12 +04:00
|
|
|
Team* GetTeam() const { return fTeam; }
|
|
|
|
thread_id ID() const { return fID; }
|
2009-06-16 04:25:36 +04:00
|
|
|
|
|
|
|
const char* Name() const { return fName.String(); }
|
|
|
|
void SetName(const BString& name);
|
|
|
|
|
2009-06-18 04:35:12 +04:00
|
|
|
uint32 State() const { return fState; }
|
|
|
|
void SetState(uint32 state);
|
2009-06-16 04:25:36 +04:00
|
|
|
|
|
|
|
private:
|
2009-06-18 04:35:12 +04:00
|
|
|
Team* fTeam;
|
2009-06-16 04:25:36 +04:00
|
|
|
thread_id fID;
|
|
|
|
BString fName;
|
2009-06-18 04:35:12 +04:00
|
|
|
uint32 fState;
|
2009-06-16 04:25:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef DoublyLinkedList<Thread> ThreadList;
|
|
|
|
|
|
|
|
|
|
|
|
#endif // THREAD_H
|