当前位置: 首页>>代码示例>>C++>>正文


C++ CLStatus类代码示例

本文整理汇总了C++中CLStatus的典型用法代码示例。如果您正苦于以下问题:C++ CLStatus类的具体用法?C++ CLStatus怎么用?C++ CLStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CLStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Initialize

CLStatus CLMessageLoopManager::EnterMessageLoop(void *pContext)
{
	CLStatus s = Initialize();
	if(!s.IsSuccess())
	{
		CLLogger::WriteLogMsg("In CLMessageLoopManager::EnterMessageLoop(), Initialize error", 0);
		return CLStatus(-1, 0);
	}
	
	while(true)
	{
		CLMessage *pMsg = WaitForMessage();
		if(pMsg == 0)
		{
			CLLogger::WriteLogMsg("In CLMessageLoopManager::EnterMessageLoop(), pMsg == 0", 0);
			continue;
		}
		
		CLStatus s3 = DispatchMessage(pMsg);

		delete pMsg;

		if(s3.m_clReturnCode == QUIT_MESSAGE_LOOP)
			break;
	}

	CLStatus s4 = Uninitialize();
	if(!s4.IsSuccess())
	{
		CLLogger::WriteLogMsg("In CLMessageLoopManager::EnterMessageLoop(), Uninitialize() error", 0);
		return CLStatus(-1, 0);
	}

	return CLStatus(0, 0);
}
开发者ID:unix1986,项目名称:universe,代码行数:35,代码来源:CLMessageLoopManager.cpp

示例2: CLStatus

CLStatus CLThreadForMsgLoop::Run(void *pContext)
{
	if(m_pCoordinator == 0)
		return CLStatus(-1, 0);
	CLEvent event;
	CLThreadInitialFinishedNotifier notifier(&event);
	SLExecutiveInitialParameter para;//打包通知变量和运行参数
	para.pContext = pContext;
	para.pNotifier = &notifier;

	CLStatus s = m_pCoordinator->Run(&para);
	if(!s.IsSuccess())
	{
		CLLogger::WriteLogMesg("In CLThreadForMsgLoop::Run(), m_pThread->Run error", 0);
		m_bWaitForDeath = false;
		m_pCoordinator = 0;
		return CLStatus(-1, 0);
	}
	CLStatus s1 = event.Wait();
	if(!s1.IsSuccess())
		CLLogger::WriteLogMesg("In CLThreadForMsgLoop::Run(), event.Wait error", 0);
	if(notifier.IsInitialSuccess())
		return CLStatus(0,0);
	else
		return CLStatus(-1,0);

}
开发者ID:ashimidashajia,项目名称:LibExcutor,代码行数:27,代码来源:CLThreadForMsgLoop.cpp

示例3: cs

CLStatus CLEvent::Wait()
{
	try
	{
		CLCriticalSection cs(&m_Mutex);

		while(m_Flag == 0)
		{
			CLStatus s = m_Cond.Wait(&m_Mutex);
			if(!s.IsSuccess())
			{
				CLLogger::WriteLogMsg("In CLEvent::Wait(), m_Cond.Wait error", 0);
				return CLStatus(-1, 0);
			}
		}

		m_Flag = 0;
	}
	catch(const char* str)
	{
		CLLogger::WriteLogMsg("In CLEvent::Wait(), exception arise", 0);
		return CLStatus(-1, 0);
	}
	
	return CLStatus(0, 0);
}
开发者ID:unix1986,项目名称:universe,代码行数:26,代码来源:CLEvent.cpp

示例4: Initialize

CLStatus CLMessageLoopManager::EnterMessageLoop(void *pContext)
{
	SLExecutiveInitialParameter *para = (SLExecutiveInitialParameter *)pContext;
	CLStatus s = Initialize();//队列(管道,网络等对象)等的初始化工作
	if(!s.IsSuccess())
	{
		throw "In CLMessageLoopManager::EnterMessageLoop(), Initialize() error.";
		para->pNotifier->NotifyInitialFinished(false);
		return CLStatus(-1,0);
	}
	CLStatus s1 = m_pMessageOberver->Initialize(this,para->pContext);//初始化CLMessageOberver对象,如注册不同消息的处理方法
	if(!s1.IsSuccess())
	{
		throw "In CLMessageLoopManager::EnterMessageLoop(), m_pMessageOberver->Initialize error.";
		para->pNotifier->NotifyInitialFinished(false);
		return CLStatus(-1,0);
	}
	para->pNotifier->NotifyInitialFinished(true);

	while(true)
	{
		CLMessage *pMsg = WaitForMessage();
		CLStatus s3 = DispatchMessage(pMsg);
		if(s3.m_clReturnCode == QUIT_MESSAGE_LOOP)  //注意此退出返回码要与QUIT_MESSAGE_LOOP保持一致
			break;
		delete pMsg;
	}
	delete m_pMessageOberver; //所有消息处理完毕,删除消息处理方法CLMessageOberver对象
	m_pMessageOberver = 0;  //这里加入了赋值语句,使得m_pMessageOberver = 0,因为在本类的析构中还释放了一次,造成segmentation fault
	CLStatus s4 = Uninitialize();//反初始化队列(管道,网络等对象)等
	return CLStatus(0,0);
}
开发者ID:ashimidashajia,项目名称:LibExcutor,代码行数:32,代码来源:CLMessageLoopManager.cpp

示例5: CLStatus

CLStatus CLLogger::writeLog(const char *msg, long errorCode){
	if(msg == 0)
		return CLStatus(-1,0);
	
	if(strlen(msg) == 0)
		return CLStatus(-1,0);
	
	if(fileFd == -1)
		return CLStatus(-1,0);
	
	//带缓冲区的日志类代码实现
	unsigned int nLeftRoom = BUFFER_SIZE_LOG_FILE - usedByteForBuffer;

	unsigned int lengthOfMsg = strlen(msg);

	char buf[MAX_LINE];
	snprintf(buf,MAX_LINE," Error code:%d\r\n",errorCode);
	unsigned int lengthOfCode = strlen(buf);

	unsigned int totalLen = lengthOfMsg + lengthOfCode;
	if(totalLen > BUFFER_SIZE_LOG_FILE){
		CLStatus s = flush();
		if(!s.isSuccess())
			return CLStatus(-1,0);
	
		ssize_t r = write(fileFd,msg,lengthOfMsg);
		if(r == -1)
			return CLStatus(-1,errno);

		r = write(fileFd,buf,lengthOfCode);
		if(r == -1)
			return CLStatus(-1,errno);
	}

	if(totalLen > nLeftRoom){
		CLStatus s = flush();
		if(!s.isSuccess())
			return CLStatus(-1,0);
	}

	memcpy(logBuffer + usedByteForBuffer,msg,lengthOfMsg);
	usedByteForBuffer += lengthOfMsg;
	memcpy(logBuffer + usedByteForBuffer,buf,lengthOfCode);
	usedByteForBuffer += lengthOfCode;

	/*不带缓冲区的日志类代码实现。
	 * ssize_t n = write(fileFd,msg,strlen(msg));
	if(n < 0)
		return CLStatus(-1,errno);
	
	char buf[MAX_LINE];
	snprintf(buf,MAX_LINE," Error code:%d\r\n",errorCode);

	n = write(fileFd, buf, strlen(buf));
	if(n < 0){
		return CLStatus(-1,errno);
	}*/

	return CLStatus(0,0);
}
开发者ID:linkpark,项目名称:study,代码行数:60,代码来源:CLLogger.cpp

示例6: TestThreadForCLLogger

static void* TestThreadForCLLogger(void *arg)
{
	for(int j = 0; j < 1000; j++)
	{
		CLStatus s = CLLogger::GetInstance()->WriteLog("ddd", 5);
		EXPECT_TRUE(s.IsSuccess());
	}
}
开发者ID:JsHuang,项目名称:LibExecutive,代码行数:8,代码来源:CLLoggerTester.cpp

示例7: GetInstance

CLStatus CLLogger::WriteLogMsg(const char* pstrMsg, long lErrorCode) {
	CLLogger* pLog = GetInstance();
	if(pLog == 0) return CLStatus(-1,0);
	CLStatus s = pLog->WriteLog(pstrMsg, lErrorCode);
	if(s.IsSuccess()) 
		return CLStatus(0,0);
	else
		return CLStatus(-1,0);
}
开发者ID:jerk1991,项目名称:Thread,代码行数:9,代码来源:CLLogger.cpp

示例8: CLStatus

CLStatus CLMsgLoopManagerForSTLqueue::Initialize()
{
	if(m_pMsgReceiver == 0)
		return CLStatus(-1, 0);

	CLMessagePoster *pMsgPoster = 0;

	try
	{
		CLExecutiveNameServer *pNameServer = CLExecutiveNameServer::GetInstance();
		if(pNameServer == 0)
		{
			CLLogger::WriteLogMsg("In CLMsgLoopManagerForSTLqueue::Initialize(), CLExecutiveNameServer::GetInstance error", 0);
			throw CLStatus(-1, 0);
		}

		pMsgPoster = new CLMessagePoster(new CLMsgToPointerSerializer, 0, new CLDataPostChannelBySTLqueueMaintainer(m_pSTLqueue), m_pEvent);

		CLStatus s2 = pMsgPoster->Initialize(new CLInitialDataPostChannelNotifier(), 0);
		if(!s2.IsSuccess() && (s2.m_clErrorCode == DATA_POSTER_INITIALIZE_ERROR))
		{
			CLLogger::WriteLogMsg("In CLMsgLoopManagerForSTLqueue::Initialize(), pMsgPoster->Initialize error", 0);
			throw CLStatus(-1, 0);
		}
		
		CLStatus s = pNameServer->Register(m_strThreadName.c_str(), pMsgPoster, m_pMsgReceiver);
		if(!s.IsSuccess())
		{
			CLLogger::WriteLogMsg("In CLMsgLoopManagerForSTLqueue::Initialize(), pNameServer->Register error", 0);
			
			m_pMsgReceiver = 0;
			return CLStatus(-1, 0);
		}

		return CLStatus(0, 0);
	}
	catch(CLStatus& s1)
	{
		if(m_pMsgReceiver)
		{
			delete m_pMsgReceiver;
			m_pMsgReceiver = 0;
		}

		if(pMsgPoster)
			delete pMsgPoster;
		else
		{
			delete m_pEvent;
			delete m_pSTLqueue;
		}

		return s1;
	}
}
开发者ID:ChengHuaUESTC,项目名称:LibExecutive,代码行数:55,代码来源:CLMsgLoopManagerForSTLqueue.cpp

示例9:

CLThreadForMsgLoop::~CLThreadForMsgLoop()
{
	if((m_bWaitForDeath) && (m_pCoordinator != 0))
	{
		CLStatus s = m_pCoordinator->WaitForDeath();   //注意此处,必须要调用~CLThreadForMsgLoop的析构函数能能WaitForDeath!
		if(!s.IsSuccess())
			CLLogger::WriteLogMesg("In CLThreadForMsgLoop::~CLThreadForMsgLoop(), m_pCoordinator->WaitForDeath error", 0);
	}
	if(m_pCoordinator != 0)
		delete m_pCoordinator;
}
开发者ID:ashimidashajia,项目名称:LibExcutor,代码行数:11,代码来源:CLThreadForMsgLoop.cpp

示例10: CLStatus

CLStatus CLLogger::writeLogMessage(const char *msg, long errorCode){
	CLLogger *log = CLLogger::getInstance();
	if(log == 0)
		return CLStatus(0,0);
	
	CLStatus s = log->writeLog(msg,errorCode);
	if(s.isSuccess())
		return CLStatus(0,0);
	else
		return CLStatus(-1,0);
}
开发者ID:linkpark,项目名称:crawlerAgent,代码行数:11,代码来源:CLLogger.cpp

示例11: GetMessage

CLMessage* CLMessageQueueByNamedPipe::GetMessage()
{
	CLStatus s = m_Event.Wait();
	if(!s.IsSuccess())
	{
		CLLogger::WriteLogMsg("In CLMessageQueueByNamedPipe::GetMessage(), m_Event.Wait error", 0);
		return 0;
	}

	return ReadMsgFromPipe(m_Fd);
}
开发者ID:unix1986,项目名称:universe,代码行数:11,代码来源:CLMessageQueueByNamedPipe.cpp

示例12: GetMessage

CLMessage* CLMessageQueueBySTLqueue::GetMessage()
{
	CLStatus s = m_Event.Wait();
	if(!s.IsSuccess())
	{
		CLLogger::WriteLogMsg("In CLMessageQueue::GetMessage(), m_Event.Wait error", 0);
		return 0;
	}

	return Pop();
}
开发者ID:unix1986,项目名称:universe,代码行数:11,代码来源:CLMessageQueueBySTLqueue.cpp

示例13: CLStatus

CLStatus CLLogger::WriteLog(const char *pstrMsg, long lErrorCode)
{
	if(pstrMsg == 0)
		return CLStatus(-1, 0);

	if(strlen(pstrMsg) == 0)
		return CLStatus(-1, 0);

	if(m_pLogBuffer == 0)
		return CLStatus(-1, 0);
	
	unsigned int nleftroom = BUFFER_SIZE_LOG_FILE - m_nUsedBytesForBuffer;

	unsigned int len_strmsg = strlen(pstrMsg);

	char buf[MAX_SIZE];
	snprintf(buf, MAX_SIZE, "	Error code: %ld\r\n",  lErrorCode);
	unsigned int len_code = strlen(buf);

	unsigned int total_len = len_code + len_strmsg;
	if(total_len > BUFFER_SIZE_LOG_FILE)
	{
		if(m_Fd == -1)
			return CLStatus(-1, 0);

		ssize_t r = write(m_Fd, pstrMsg, len_strmsg);
		if(r == -1)
			return CLStatus(-1, errno);

		r = write(m_Fd, buf, len_code);
		if(r == -1)
			return CLStatus(-1, errno);

		return CLStatus(0, 0);
	}

	if(total_len > nleftroom)
	{
		CLStatus s = Flush();
		if(!s.IsSuccess())
			return CLStatus(-1, 0);
	}

	memcpy(m_pLogBuffer + m_nUsedBytesForBuffer, pstrMsg, len_strmsg);

	m_nUsedBytesForBuffer += len_strmsg;

	memcpy(m_pLogBuffer + m_nUsedBytesForBuffer, buf, len_code);

	m_nUsedBytesForBuffer += len_code;
	
	return CLStatus(0, 0);
}
开发者ID:unix1986,项目名称:universe,代码行数:53,代码来源:CLLogger.cpp

示例14: RunExecutiveFunction

	virtual CLStatus RunExecutiveFunction(void* pContext)
	{
		for(int i = 0; i < count; i++)
		{
			CLStatus s = CLExecutiveNameServer::PostExecutiveMessage(test_pipe_name, new CLMsg1ForCLNonThreadForMsgLoop);
			if(!s.IsSuccess())
			{
				sleep(1);
				CLExecutiveNameServer::PostExecutiveMessage(test_pipe_name, new CLMsg1ForCLNonThreadForMsgLoop);
			}
		}
	}
开发者ID:JsHuang,项目名称:LibExecutive,代码行数:12,代码来源:CLNonThreadForMsgLoopTester.cpp

示例15: GetMessage

CLMessage * CLMessageQueueBySTLList :: GetMessage() {
  //Wait until the message has arrived,
  CLStatus s = m_Event.Wait();
  if(!s.IsSuccess())
    return 0;
  CLMessage * pMessage = 0;
  {
    CLCriticalSection cs(&m_Mutex);
    pMessage = m_MessageQueue.front();
    m_MessageQueue.pop_front(); //message obj still exits
  }

  return pMessage;
}
开发者ID:alianpaul,项目名称:linuxcodechapter3,代码行数:14,代码来源:CLMessageQueueBySTLList.cpp


注:本文中的CLStatus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。