Ejemplo n.º 1
0
//============================================================================
//		NTargetThread::ThreadSetName : Set the current thread name.
//----------------------------------------------------------------------------
void NTargetThread::ThreadSetName(const NString &theName)
{	StLock							acquireLock(gThreadNameLock);
	NThreadID			theID;



	// Get the state we need
	theID = ThreadGetID();

	gThreadNames[theID] = theName;
}
Ejemplo n.º 2
0
//============================================================================
//		NTargetThread::ThreadGetName : Get the current thread name.
//----------------------------------------------------------------------------
NString NTargetThread::ThreadGetName(void)
{	StLock							acquireLock(gThreadNameLock);
	ThreadNameMapConstIterator		theIter;
	NString							theName;



	// Get the name
	theIter = gThreadNames.find(ThreadGetID());
	if (theIter != gThreadNames.end())
		theName = theIter->second;
	
	return(theName);
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
    //ShowVersion();

    g_TimerManager.Start();
    g_ThreadManager.RegisterMainThread(ThreadGetID());
#ifdef USE_EZCONFIG

    g_Config.initialize(ConfigFile_1, ConfigFile_2);

#endif //USE_EZCONFIG

#ifdef EXAMPLE_GENERALAGENTTCPSOCKETCONNECTOR

    GENERALAGENTCFG_T g_ConnPara;

    GENERALSERVERCFG_T __NvrServer;

    //连接超时属性 针对tcp客户端
    __NvrServer.iConnTimeOut = 5;
    __NvrServer.iConnTimes = 0;
    //重连属性 针对tcp客户端
    __NvrServer.bEnableRecon = true;
    __NvrServer.iInterval = 3;
    // 对方服务器属性 针对tcp客户端
    __NvrServer.strHost = "192.168.10.24";
    __NvrServer.Port = 6000;
    __NvrServer.strUName = "admin";
    __NvrServer.strUPwd = "12345";
    __NvrServer.strServerName = "NVR_KEEPCONNECTOR_SOCKET_NAME";

    g_ConnPara.TcpHost.push_back(__NvrServer);

    //g_GeneralAgent.Start(&g_ConnPara);
    g_GeneralAgent.Initialize(argc, argv);
    g_GeneralAgent.Start();
#else

    g_GeneralAgent.Initialize(argc, argv);

    // 开启
    g_GeneralAgent.Start();
#endif // #ifdef EXAMPLE_GENERALAGENTTCPSOCKETCONNECTOR

#ifdef EXAMPLE_THE_WEBSERVICE

    g_AgentWebService.Start();
#endif

    // main线程等待
    while (1)
    {
    	// 测试用
        printf("press any key to g_GeneralAgent.ConnectorDestroy ...\n");
        getchar();

        g_GeneralAgent.ConnectorDestroy();
        printf("g_GeneralAgent.ConnectorDestroy DONE.\n");

        printf("press any key to g_GeneralAgent.ConnectorCreate ...\n");
        getchar();
        g_GeneralAgent.ConnectorCreate();
        printf("g_GeneralAgent.ConnectorCreate DONE.\n");
    }

    return 0;
}