First round of style changes: renamed all member variables from m_var_name to fVarName

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27445 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2008-09-12 09:55:02 +00:00
parent fa23653d48
commit b5d458a508
2 changed files with 85 additions and 44 deletions
+77 -36
View File
@@ -5,25 +5,27 @@
#include <string.h> #include <string.h>
GenericThread::GenericThread(const char * a_thread_name, int32 a_priority, BMessage * a_message) GenericThread::GenericThread(const char * thread_name, int32 a_priority, BMessage * message)
: :
m_thread_data_store(a_message), fThreadDataStore(message),
m_thread_id(spawn_thread(private_thread_function, a_thread_name, a_priority, this)), fThreadId(spawn_thread(private_thread_function, thread_name, a_priority, this)),
m_execute_unit(create_sem(1, "m_execute_unit")), fExecuteUnit(create_sem(1, "ExecuteUnit sem")),
m_quit_requested(false), fQuitRequested(false),
m_thread_is_paused(false) fThreadIsPaused(false)
{ {
if (m_thread_data_store == NULL) if (fThreadDataStore == NULL)
m_thread_data_store = new BMessage(); fThreadDataStore = new BMessage();
} }
GenericThread::~GenericThread() GenericThread::~GenericThread()
{ {
kill_thread(m_thread_id); kill_thread(fThreadId);
delete_sem(m_execute_unit); delete_sem(fExecuteUnit);
} }
status_t status_t
GenericThread::ThreadFunction(void) GenericThread::ThreadFunction(void)
{ {
@@ -65,6 +67,7 @@ GenericThread::ThreadFunction(void)
return (B_OK); return (B_OK);
} }
status_t status_t
GenericThread::ThreadStartup(void) GenericThread::ThreadStartup(void)
{ {
@@ -87,6 +90,7 @@ GenericThread::ExecuteUnit(void)
return B_OK; return B_OK;
} }
status_t status_t
GenericThread::ThreadShutdown(void) GenericThread::ThreadShutdown(void)
{ {
@@ -96,6 +100,7 @@ GenericThread::ThreadShutdown(void)
return B_OK; return B_OK;
} }
void void
GenericThread::ThreadStartupFailed(status_t a_status) GenericThread::ThreadStartupFailed(status_t a_status)
{ {
@@ -105,6 +110,7 @@ GenericThread::ThreadStartupFailed(status_t a_status)
Quit(); Quit();
} }
void void
GenericThread::ExecuteUnitFailed(status_t a_status) GenericThread::ExecuteUnitFailed(status_t a_status)
{ {
@@ -114,6 +120,7 @@ GenericThread::ExecuteUnitFailed(status_t a_status)
Quit(); Quit();
} }
void void
GenericThread::ThreadShutdownFailed(status_t a_status) GenericThread::ThreadShutdownFailed(status_t a_status)
{ {
@@ -123,6 +130,7 @@ GenericThread::ThreadShutdownFailed(status_t a_status)
// (is this good default behaviour?) // (is this good default behaviour?)
} }
status_t status_t
GenericThread::Start(void) GenericThread::Start(void)
{ {
@@ -130,18 +138,19 @@ GenericThread::Start(void)
if (IsPaused()) if (IsPaused())
{ {
status = release_sem(m_execute_unit); status = release_sem(fExecuteUnit);
if (status != B_OK) if (status != B_OK)
return status; return status;
m_thread_is_paused = false; fThreadIsPaused = false;
} }
status = resume_thread(m_thread_id); status = resume_thread(fThreadId);
return status; return status;
} }
int32 int32
GenericThread::private_thread_function(void * a_simple_thread_ptr) GenericThread::private_thread_function(void * a_simple_thread_ptr)
{ {
@@ -152,126 +161,144 @@ GenericThread::private_thread_function(void * a_simple_thread_ptr)
return (status); return (status);
} }
BMessage * BMessage *
GenericThread::GetDataStore(void) GenericThread::GetDataStore(void)
{ {
return (m_thread_data_store); return (fThreadDataStore);
} }
void void
GenericThread::SetDataStore(BMessage * a_message) GenericThread::SetDataStore(BMessage * message)
{ {
m_thread_data_store = a_message; fThreadDataStore = message;
} }
status_t status_t
GenericThread::Pause(bool a_do_block, bigtime_t a_timeout) GenericThread::Pause(bool a_do_block, bigtime_t a_timeout)
{ {
status_t status = B_OK; status_t status = B_OK;
if (a_do_block) if (a_do_block)
status = acquire_sem(m_execute_unit); status = acquire_sem(fExecuteUnit);
// thread will wait on semaphore // thread will wait on semaphore
else else
status = acquire_sem_etc(m_execute_unit, 1, B_RELATIVE_TIMEOUT, a_timeout); status = acquire_sem_etc(fExecuteUnit, 1, B_RELATIVE_TIMEOUT, a_timeout);
// thread will timeout // thread will timeout
if (status == B_OK) if (status == B_OK)
{ {
m_thread_is_paused = true; fThreadIsPaused = true;
return (B_OK); return (B_OK);
} }
return status; return status;
} }
void void
GenericThread::Quit(void) GenericThread::Quit(void)
{ {
m_quit_requested = true; fQuitRequested = true;
} }
bool bool
GenericThread::HasQuitBeenRequested(void) GenericThread::HasQuitBeenRequested(void)
{ {
return (m_quit_requested); return (fQuitRequested);
} }
bool bool
GenericThread::IsPaused(void) GenericThread::IsPaused(void)
{ {
return (m_thread_is_paused); return (fThreadIsPaused);
} }
status_t status_t
GenericThread::Suspend(void) GenericThread::Suspend(void)
{ {
return (suspend_thread(m_thread_id)); return (suspend_thread(fThreadId));
} }
status_t status_t
GenericThread::Resume(void) GenericThread::Resume(void)
{ {
release_sem(m_execute_unit); // to counteract Pause() release_sem(fExecuteUnit); // to counteract Pause()
m_thread_is_paused = false; fThreadIsPaused = false;
return (resume_thread(m_thread_id)); // to counteract Suspend() return (resume_thread(fThreadId)); // to counteract Suspend()
} }
status_t status_t
GenericThread::Kill(void) GenericThread::Kill(void)
{ {
return (kill_thread(m_thread_id)); return (kill_thread(fThreadId));
} }
void void
GenericThread::ExitWithReturnValue(status_t a_return_value) GenericThread::ExitWithReturnValue(status_t a_return_value)
{ {
exit_thread(a_return_value); exit_thread(a_return_value);
} }
status_t status_t
GenericThread::SetExitCallback(void(*a_callback)(void*), void * a_data) GenericThread::SetExitCallback(void(*a_callback)(void*), void * a_data)
{ {
return (on_exit_thread(a_callback, a_data)); return (on_exit_thread(a_callback, a_data));
} }
status_t status_t
GenericThread::WaitForThread(status_t * a_exit_value) GenericThread::WaitForThread(status_t * a_exit_value)
{ {
return (wait_for_thread(m_thread_id, a_exit_value)); return (wait_for_thread(fThreadId, a_exit_value));
} }
status_t status_t
GenericThread::Rename(char * a_name) GenericThread::Rename(char * a_name)
{ {
return (rename_thread(m_thread_id, a_name)); return (rename_thread(fThreadId, a_name));
} }
status_t status_t
GenericThread::SendData(int32 a_code, void * a_buffer, size_t a_buffer_size) GenericThread::SendData(int32 a_code, void * a_buffer, size_t a_buffer_size)
{ {
return (send_data(m_thread_id, a_code, a_buffer, a_buffer_size)); return (send_data(fThreadId, a_code, a_buffer, a_buffer_size));
} }
int32 int32
GenericThread::ReceiveData(thread_id * a_sender, void * a_buffer, size_t a_buffer_size) GenericThread::ReceiveData(thread_id * a_sender, void * a_buffer, size_t a_buffer_size)
{ {
return (receive_data(a_sender, a_buffer, a_buffer_size)); return (receive_data(a_sender, a_buffer, a_buffer_size));
} }
bool bool
GenericThread::HasData(void) GenericThread::HasData(void)
{ {
return (has_data(m_thread_id)); return (has_data(fThreadId));
} }
status_t status_t
GenericThread::SetPriority(int32 a_new_priority) GenericThread::SetPriority(int32 a_new_priority)
{ {
return (set_thread_priority(m_thread_id, a_new_priority)); return (set_thread_priority(fThreadId, a_new_priority));
} }
void void
GenericThread::Snooze(bigtime_t a_microseconds) GenericThread::Snooze(bigtime_t a_microseconds)
{ {
@@ -280,6 +307,7 @@ GenericThread::Snooze(bigtime_t a_microseconds)
Resume(); Resume();
} }
void void
GenericThread::SnoozeUntil(bigtime_t a_microseconds, int a_timebase) GenericThread::SnoozeUntil(bigtime_t a_microseconds, int a_timebase)
{ {
@@ -288,12 +316,14 @@ GenericThread::SnoozeUntil(bigtime_t a_microseconds, int a_timebase)
Resume(); Resume();
} }
status_t status_t
GenericThread::GetInfo(thread_info * a_thread_info) GenericThread::GetInfo(thread_info * thread_info)
{ {
return (get_thread_info(m_thread_id, a_thread_info)); return (get_thread_info(fThreadId, thread_info));
} }
thread_id thread_id
GenericThread::GetThread(void) GenericThread::GetThread(void)
{ {
@@ -302,6 +332,7 @@ GenericThread::GetThread(void)
return (t_thread_info.thread); return (t_thread_info.thread);
} }
team_id team_id
GenericThread::GetTeam(void) GenericThread::GetTeam(void)
{ {
@@ -310,6 +341,7 @@ GenericThread::GetTeam(void)
return (t_thread_info.team); return (t_thread_info.team);
} }
char * char *
GenericThread::GetName(void) GenericThread::GetName(void)
{ {
@@ -318,6 +350,7 @@ GenericThread::GetName(void)
return strdup(t_thread_info.name); return strdup(t_thread_info.name);
} }
thread_state thread_state
GenericThread::GetState(void) GenericThread::GetState(void)
{ {
@@ -326,6 +359,7 @@ GenericThread::GetState(void)
return (t_thread_info.state); return (t_thread_info.state);
} }
sem_id sem_id
GenericThread::GetSemaphore(void) GenericThread::GetSemaphore(void)
{ {
@@ -334,6 +368,7 @@ GenericThread::GetSemaphore(void)
return (t_thread_info.sem); return (t_thread_info.sem);
} }
int32 int32
GenericThread::GetPriority(void) GenericThread::GetPriority(void)
{ {
@@ -342,6 +377,7 @@ GenericThread::GetPriority(void)
return (t_thread_info.priority); return (t_thread_info.priority);
} }
bigtime_t bigtime_t
GenericThread::GetUserTime(void) GenericThread::GetUserTime(void)
{ {
@@ -350,6 +386,7 @@ GenericThread::GetUserTime(void)
return (t_thread_info.user_time); return (t_thread_info.user_time);
} }
bigtime_t bigtime_t
GenericThread::GetKernelTime(void) GenericThread::GetKernelTime(void)
{ {
@@ -358,6 +395,7 @@ GenericThread::GetKernelTime(void)
return (t_thread_info.kernel_time); return (t_thread_info.kernel_time);
} }
void * void *
GenericThread::GetStackBase(void) GenericThread::GetStackBase(void)
{ {
@@ -366,6 +404,7 @@ GenericThread::GetStackBase(void)
return (t_thread_info.stack_base); return (t_thread_info.stack_base);
} }
void * void *
GenericThread::GetStackEnd(void) GenericThread::GetStackEnd(void)
{ {
@@ -374,15 +413,17 @@ GenericThread::GetStackEnd(void)
return (t_thread_info.stack_end); return (t_thread_info.stack_end);
} }
void void
GenericThread::BeginUnit(void) GenericThread::BeginUnit(void)
{ {
acquire_sem(m_execute_unit); // thread can not be paused until it releases semaphore acquire_sem(fExecuteUnit); // thread can not be paused until it releases semaphore
} }
void void
GenericThread::EndUnit(void) GenericThread::EndUnit(void)
{ {
release_sem(m_execute_unit); // thread can now be paused release_sem(fExecuteUnit); // thread can now be paused
} }
+8 -8
View File
@@ -7,11 +7,11 @@
class GenericThread class GenericThread
{ {
public: public:
GenericThread(const char * a_thread_name = "generic_thread", int32 a_priority = B_NORMAL_PRIORITY, BMessage * a_message = NULL); GenericThread(const char * thread_name = "generic_thread", int32 a_priority = B_NORMAL_PRIORITY, BMessage * message = NULL);
virtual ~GenericThread(void); virtual ~GenericThread(void);
BMessage * GetDataStore(void); BMessage * GetDataStore(void);
void SetDataStore(BMessage * a_message); void SetDataStore(BMessage * message);
status_t Start(void); status_t Start(void);
status_t Pause(bool a_do_block = TRUE, bigtime_t a_timeout = 0); status_t Pause(bool a_do_block = TRUE, bigtime_t a_timeout = 0);
@@ -39,7 +39,7 @@ class GenericThread
void SnoozeUntil(bigtime_t a_microseconds, int a_timebase = B_SYSTEM_TIMEBASE); void SnoozeUntil(bigtime_t a_microseconds, int a_timebase = B_SYSTEM_TIMEBASE);
status_t GetInfo(thread_info * a_thread_info); status_t GetInfo(thread_info * thread_info);
thread_id GetThread(void); thread_id GetThread(void);
team_id GetTeam(void); team_id GetTeam(void);
char * GetName(void); char * GetName(void);
@@ -65,18 +65,18 @@ class GenericThread
void BeginUnit(void); // acquire m_execute_cycle void BeginUnit(void); // acquire m_execute_cycle
void EndUnit(void); // release m_execute_cycle void EndUnit(void); // release m_execute_cycle
BMessage * m_thread_data_store; BMessage * fThreadDataStore;
private: private:
static status_t private_thread_function(void * a_simple_thread_ptr); static status_t private_thread_function(void * a_simple_thread_ptr);
thread_id m_thread_id; thread_id fThreadId;
sem_id m_execute_unit; // acq./relase within tread_function.. For Pause() sem_id fExecuteUnit; // acq./relase within tread_function.. For Pause()
bool m_quit_requested; bool fQuitRequested;
bool m_thread_is_paused; bool fThreadIsPaused;
}; };