#include <thread.h>

cmn_Thread is currently based on AT&T's omni_thread, which is a part of CORBA ORB omniORB.
There are two ways of defining which function will be executed in a thread:
Threads can run in either detached or undetached mode:
Use this mode if you will not need to control the thread. System does resource cleanup automatically after the thread terminates. You can't use Join() for detached threads.
To start a thread in detached mode, use cmn_Thread::Start().
void ThreadMain(void *arg) type of function must be used if passed as a parameter. Function does not return a value.
System does not clean thread's resources after the thread completes. You must use Join() to delete thread's resources and you must have a reference to the thread stored somewhere to do the Join() operation.
To start a thread in undetached mode, use cmn_Thread::StartUndetached().
void *ThreadMain(void *arg) type of function must be used if passed as a parameter. (Function returns a value!)
The preferred mode to use is detached mode. If the thread performs data processing that must be returned to the creator thread then there are other means of passing the value back.
For instance: the argument that is passed to the thread can be used to store the results and a condition (cmn_Condition::Wait() and cmn_Condition::Signal()) can be used to inform the creator that the thread has finished.
Definition at line 186 of file thread.h.
Public Types | |
| enum | ThPriority_e { PRIO_LOW = omni_thread::PRIORITY_LOW, PRIO_NORM = omni_thread::PRIORITY_NORMAL, PRIO_HIGH = omni_thread::PRIORITY_HIGH } |
| enum | ThState_e { ST_NEW = omni_thread::STATE_NEW, ST_RUNNING = omni_thread::STATE_RUNNING, ST_TERM = omni_thread::STATE_TERMINATED } |
Public Member Functions | |
| cmn_Thread (void(*fn)(void *), void *arg=NULL, ThPriority_e a_pri=PRIO_NORM) | |
| cmn_Thread (void *(*fn)(void *), void *arg=NULL, ThPriority_e a_pri=PRIO_NORM) | |
| void | Start () |
| void | StartUndetached () |
| void | Join (void **arg) |
| void | SetPriority (ThPriority_e a_prio) |
| ThPriority_e | Priority () |
| ThState_e | State () |
| int | Id () |
Static Public Member Functions | |
| static cmn_Thread * | Create (void(*fn)(void *), void *arg=NULL, ThPriority_e pri=PRIO_NORM) |
| static cmn_Thread * | Create (void *(*fn)(void *), void *arg=NULL, ThPriority_e pri=PRIO_NORM) |
| static void | Exit (void *return_value=NULL) |
| static cmn_Thread * | Self () |
| static void | YieldThread () |
| static void | Sleep (unsigned long secs, unsigned long nanosecs=0) |
| static ivd_Time32_t | GetTime (unsigned long rel_sec=0) |
| static void | StackSize (unsigned long sz) |
| static unsigned long | StackSize () |
Protected Member Functions | |
| cmn_Thread (void *arg=NULL, ThPriority_e a_pri=PRIO_NORM) | |
Private Member Functions | |
| virtual void | Run (void *arg) |
| virtual void * | RunUndetached (void *arg) |
Private Attributes | |
| log_CLASSID_m | |
| ST_NEW | Thread object exists but thread hasn't started yet. |
| ST_RUNNING | Thread is running. |
| ST_TERM |
Thread has terminated but storage has not been reclaimed (i.e.
waiting to be joined) |
Definition at line 195 of file thread.h.
00195 { 00197 ST_NEW = omni_thread::STATE_NEW, 00199 ST_RUNNING = omni_thread::STATE_RUNNING, 00203 ST_TERM = omni_thread::STATE_TERMINATED 00204 };
| cmn_Thread::cmn_Thread | ( | void(*)(void *) | fn, | |
| void * | arg = NULL, |
|||
| ThPriority_e | a_pri = PRIO_NORM | |||
| ) | [inline] |
| cmn_Thread::cmn_Thread | ( | void *(*)(void *) | fn, | |
| void * | arg = NULL, |
|||
| ThPriority_e | a_pri = PRIO_NORM | |||
| ) | [inline] |
| cmn_Thread::cmn_Thread | ( | void * | arg = NULL, |
|
| ThPriority_e | a_pri = PRIO_NORM | |||
| ) | [inline, protected] |
| void cmn_Thread::Start | ( | ) |
Definition at line 305 of file cmn_thread.cpp.
References log_FUNC_m, and OMNITHREAD_EXEC_m.
Referenced by i_MigrationJob_i::AssignResources(), i_FSC_i::CheckWithMedVolume(), Create(), i_FSC_i::FSCRecovery(), i_BackupAgent_i::i_BackupAgent_i(), i_MaintFriJob_i::i_MaintFriJob_i(), i_ResourceManager_i::i_ResourceManager_i(), i_RestoreAgent_i::i_RestoreAgent_i(), rm_Queue::Init(), main(), i_RecallJob_i::MediumOperationComplete(), i_BackEndAgent_i::Migrate(), bea_MigrationThread::Migrate(), df_Writer::NewDiskBuffer(), df_Unpacker::NewDiskBuffer(), df_BlockReader::NewDiskBuffer(), df_Writer::NewFRIBuffer(), df_Unpacker::NewFRIBuffer(), df_BlockReader::NewFRIBuffer(), df_Writer::NewNetBuffer(), df_Unpacker::NewNetBuffer(), df_BlockReader::NewNetBuffer(), df_Writer::NewStdIOBuffer(), df_Unpacker::NewStdIOBuffer(), i_BackEndAgent_i::ReadFastRecoveryInfo(), i_BackEndAgent_i::Recall(), i_BackEndAgent_i::RecreateFastRecoveryInfo(), i_Job_i::Start(), hsm_Containers::Start(), i_BackEndAgent_i::VolDupRead(), and i_BackEndAgent_i::VolDupWrite().
00305 { 00306 log_FUNC_m(Start); 00307 00308 OMNITHREAD_EXEC_m(Start, start()); 00309 }

| void cmn_Thread::StartUndetached | ( | ) |
Definition at line 312 of file cmn_thread.cpp.
References log_FUNC_m, and OMNITHREAD_EXEC_m.
Referenced by ipc_Corba::Init().
00312 { 00313 log_FUNC_m(StartUndetached); 00314 00315 // Run omni_thread's function 00316 OMNITHREAD_EXEC_m(StartUndetached, start_undetached()); 00317 }

| void cmn_Thread::Join | ( | void ** | arg | ) |
Definition at line 319 of file cmn_thread.cpp.
References log_FUNC_m, and OMNITHREAD_EXEC_m.
Referenced by ipc_Corba::Destroy().
00319 { 00320 log_FUNC_m(Join); 00321 00322 OMNITHREAD_EXEC_m(Join, join(arg)); 00323 }

| void cmn_Thread::SetPriority | ( | ThPriority_e | a_prio | ) | [inline] |
| cmn_Thread * cmn_Thread::Create | ( | void(*)(void *) | fn, | |
| void * | arg = NULL, |
|||
| ThPriority_e | pri = PRIO_NORM | |||
| ) | [static] |
Definition at line 340 of file cmn_thread.cpp.
References cmn_Thread(), log_FUNC_A_m, and Start().
Referenced by Create(), and i_Job_i::WaitBeasToFinish().
00340 { 00341 log_FUNC_A_m(Create, 00342 "<detached>" << 00343 "fn: " << fn << 00344 "arg: " << arg 00345 ); 00346 00347 cmn_Thread* t = new cmn_Thread(fn, arg, pri); 00348 t->Start(); 00349 return t; 00350 }


| cmn_Thread * cmn_Thread::Create | ( | void *(*)(void *) | fn, | |
| void * | arg = NULL, |
|||
| ThPriority_e | pri = PRIO_NORM | |||
| ) | [static] |
Definition at line 352 of file cmn_thread.cpp.
References cmn_Thread(), Create(), log_FUNC_A_m, and Start().
00352 { 00353 log_FUNC_A_m(Create, 00354 "<undetached>" << 00355 "fn: " << fn << 00356 "arg: " << arg 00357 ); 00358 00359 cmn_Thread* t = new cmn_Thread(fn, arg, pri); 00360 t->Start(); 00361 return t; 00362 }

| void cmn_Thread::Exit | ( | void * | return_value = NULL |
) | [static] |
Definition at line 325 of file cmn_thread.cpp.
References log_FUNC_m, and OMNITHREAD_EXEC_m.
00325 { 00326 log_FUNC_m(Exit); 00327 00328 OMNITHREAD_EXEC_m(Exit, exit(return_value)); 00329 }
| static cmn_Thread* cmn_Thread::Self | ( | ) | [inline, static] |
Definition at line 292 of file thread.h.
00292 { 00293 return dynamic_cast<cmn_Thread*>( self() ); 00294 };
| void cmn_Thread::YieldThread | ( | ) | [static] |
Definition at line 331 of file cmn_thread.cpp.
References OMNITHREAD_EXEC_m.
00331 { 00332 OMNITHREAD_EXEC_m(YieldThread, yield()); 00333 }
| void cmn_Thread::Sleep | ( | unsigned long | secs, | |
| unsigned long | nanosecs = 0 | |||
| ) | [static] |
Definition at line 335 of file cmn_thread.cpp.
References OMNITHREAD_EXEC_m.
00335 { 00336 OMNITHREAD_EXEC_m(Sleep, sleep(secs, nanosecs)); 00337 }
| static ivd_Time32_t cmn_Thread::GetTime | ( | unsigned long | rel_sec = 0 |
) | [inline, static] |
Definition at line 305 of file thread.h.
Referenced by df_BlockManager::GetFree(), df_BlockManager::GetFull(), cmn_ThreadCounter::WaitAllEnd(), i_Job_i::WaitBea(), i_Job_i::WaitBeasToFinish(), df_BlockManager::WaitReadersToComplete(), and df_BlockManager::WaitWriterToComplete().
00305 { 00306 unsigned long absSec, absNSec; 00307 omni_thread::get_time(&absSec, &absNSec, rel_sec, 0); 00308 return absSec; 00309 }

| static void cmn_Thread::StackSize | ( | unsigned long | sz | ) | [inline, static] |
| static unsigned long cmn_Thread::StackSize | ( | ) | [inline, static] |
| virtual void cmn_Thread::Run | ( | void * | arg | ) | [inline, private, virtual] |
Reimplemented in bea_FRIThread, bea_DupReadThread, bea_DupWriteThread, bea_MigrationThread, bea_RecallThread, bea_VolumeReader, FSEvMgrThrd, FSEvMgrThrd, hsm_FHADPRecall, hsm_FHmigc, hsm_FHrelc, hsm_TimedList, blk_BufferWriter, blk_NetWriter, blk_BufferReader, blk_NetReader, rm_DBThread, job_Executor, pm_AssignResThread, pm_RecallClientThread, pm_EfficientRecallClientThread, pm_FriProcessor, rm_QueueExecutor, and ivd_DD.
Definition at line 333 of file thread.h.
| virtual void* cmn_Thread::RunUndetached | ( | void * | arg | ) | [inline, private, virtual] |
Reimplemented in ipc_Shutdown.
Definition at line 334 of file thread.h.
References NULL.
00334 { return NULL; }
| ThPriority_e cmn_Thread::Priority | ( | ) | [inline] |
| ThState_e cmn_Thread::State | ( | ) | [inline] |
| int cmn_Thread::Id | ( | ) | [inline] |
cmn_Thread::log_CLASSID_m [private] |
Reimplemented in bea_FRIThread, bea_DupReadThread, bea_DupWriteThread, bea_MigrationThread, bea_RecallThread, bea_VolumeReader, FSEvMgrThrd, hsm_DirWaitList, hsm_FHADPRecall, hsm_FHdirty, hsm_FHmigc, hsm_FHrelc, hsm_TimedList, blk_BufferWriter, blk_DiskBufferWriter, blk_StdIOWriter, blk_DiskFRIWriter, blk_NetWriter, blk_BufferReader, blk_NetReader, blk_DiskBufferReader, blk_StdIOReader, blk_DiskFRIReader, rm_DBThread, ipc_Shutdown, job_Executor, pm_AssignResThread, pm_RecallClientThread, pm_EfficientRecallClientThread, pm_FriProcessor, rm_QueueExecutor, and ivd_DD.
1.5.6