Header:
class CGServer : public CGObject
{
public:
template< class T > CGServer* CreateServerinNewThread(
T* p_sample, const char * st_svrname );
static bool IsRunning( const char * str_svr_name );
static void * ThreadFunc( void * para ); /* only called when server
* is created in a new thread
*/
protected:
static pthread_key_t key_ServerInstance;
static void DestroyServerInstanceKey(void * stupid_para );
template< class T > inline CGServer*
CGServer::CreateServerinNewThread( T* p_sample, const char * st_svrname )
{
.............................................
CGServer* p_thisserver = dynamic_cast<CGServer*> (new T(str_svrname ));
pthread_create (&p_thisserver->theThreadId, NULL, ThreadFunc,
reinterpret_cast <void *>(p_thisserver ) );
return p_thisserver;
}
class CGServer : public CGObject
{
public:
template< class T > CGServer* CreateServerinNewThread(
T* p_sample, const char * st_svrname );
static bool IsRunning( const char * str_svr_name );
static void * ThreadFunc( void * para ); /* only called when server
* is created in a new thread
*/
protected:
static pthread_key_t key_ServerInstance;
static void DestroyServerInstanceKey(void * stupid_para );
template< class T > inline CGServer*
CGServer::CreateServerinNewThread( T* p_sample, const char * st_svrname )
{
.............................................
CGServer* p_thisserver = dynamic_cast<CGServer*> (new T(str_svrname ));
pthread_create (&p_thisserver->theThreadId, NULL, ThreadFunc,
reinterpret_cast <void *>(p_thisserver ) );
return p_thisserver;
}