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


C++ CLStatus函数代码示例

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


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

示例1: CLStatus

CLStatus CLLogger::WriteMsgAndErrcodeToFile(const char* pstrMsg, const char* pstrErrcode) {
	if(m_nUsedBytesForBuffer != 0) {
		if(write(m_fd, m_pLogBuffer, m_nUsedBytesForBuffer) == -1)
			return CLStatus(-1,0);
		m_nUsedBytesForBuffer = 0;
	}

	if(write(m_fd, pstrMsg, strlen(pstrMsg)) == -1)
		return CLStatus(-1,0);
	if(write(m_fd, pstrErrcode, strlen(pstrErrcode)) == -1)
		return CLStatus(-1,0);
	return CLStatus(0,0);
}
开发者ID:jerk1991,项目名称:Thread,代码行数:13,代码来源:CLLogger.cpp

示例2: pthread_cond_broadcast

CLStatus CLConditionVariable::WakeupAll()
{
	int r = pthread_cond_broadcast(m_pConditionVariable);
	if(r != 0)
	{
		CLLogger::WriteLogMsg("In CLConditionVariable::WakeupAll, pthread_cond_broadcast error", r);
		return CLStatus(-1, 0);
	}
	else
	{
		return CLStatus(0, 0);
	}
}
开发者ID:unix1986,项目名称:universe,代码行数:13,代码来源:CLConditionVariable.cpp

示例3: pthread_create

CLStatus CLThread::Run(void *pContext)
{	
	m_pContext = pContext;

	int r = pthread_create(&m_ThreadID, 0, StartFunctionOfThread, this);
	if(r != 0)
	{
		CLLogger::WriteLogMsg("In CLThread::Run(), pthread_create error", r);
		return CLStatus(-1, 0);
	}

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

示例4: pthread_cond_signal

CLStatus CLConditionVariable::Wakeup()
{
	int r = pthread_cond_signal(m_pConditionVariable);
	if(r != 0)
	{
		CLLogger::WriteLogMsg("In CLConditionVariable::Wakeup, pthread_cond_signal error", r);
		return CLStatus(-1, 0);
	}
	else
	{
		return CLStatus(0, 0);
	}
}
开发者ID:unix1986,项目名称:universe,代码行数:13,代码来源:CLConditionVariable.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: accept

CLStatus CLListenAgent::receiveData(){
    socklen_t clientLen;
    int clientFd;

    clientFd = accept( listenFd, (struct sockaddr*)&clientAddr, &clientLen );
    if(clientFd < 0){
        CLLogger::writeLogMessage( "CLListen:: receiveData accept error!\n",errno );
        return CLStatus( FAILED,errno );
    }
    
    CLAgent *jobAgent = new CLJobAgent(clientFd);
    CLEpoll::getInstance() -> doEvent(jobAgent,clientFd,EPOLL_CTL_ADD,EPOLLIN);

    return CLStatus( SUCCESSFUL,0 );
}
开发者ID:linkpark,项目名称:crawlerAgent,代码行数:15,代码来源:CLListenAgent.cpp

示例7: On_1

	CLStatus On_1(CLMessage *pm)
	{
		CLMsg1ForCLNonThreadForMsgLoop *p = dynamic_cast<CLMsg1ForCLNonThreadForMsgLoop*>(pm);
		EXPECT_TRUE(p != 0);

		g_for_on1++;

		if(g_for_on1 == count)
		{
			pthread->WaitForDeath();
			return CLStatus(QUIT_MESSAGE_LOOP, 0);
		}
		else
			return CLStatus(0, 0);
	}
开发者ID:JsHuang,项目名称:LibExecutive,代码行数:15,代码来源:CLNonThreadForMsgLoopTester.cpp

示例8: CLStatus

CLStatus CLMsgLoopManagerForPipeQueue::Uninitialize()
{
	CLPrivateMsgQueuebyNamedPipe *pQueue = dynamic_cast<CLPrivateMsgQueuebyNamedPipe *>(m_pMsgQueue);
	if(pQueue == 0)
		return CLStatus(0, 0);

	CLExecutiveNameServer *pNameServer = CLExecutiveNameServer::GetInstance();
	if(pNameServer == 0)
	{
		CLLogger::WriteLogMsg("In CLMsgLoopManagerForPipeQueue::Uninitialize(), CLExecutiveNameServer::GetInstance error", 0);
		return CLStatus(-1, 0);
	}

	return pNameServer->ReleaseCommunicationPtr(m_strThreadName.c_str());
}
开发者ID:JsHuang,项目名称:LibExecutive,代码行数:15,代码来源:CLMsgLoopManagerForPipeQueue.cpp

示例9: CLStatus

CLStatus CLMessageLoopManager::DispatchMessage(CLMessage* pMessage)
{
	std::map<unsigned long,CallBackForMessageLoop>::iterator iter;
	iter = m_MsgMappingTable.find(pMessage->m_clMsgID);
	if(iter == m_MsgMappingTable.end())
	{
		CLLogger::WriteLogMesg("In CLMessageLoopManager::DispatchMessage(), it == m_MsgMappingTable.end", 0);
		return CLStatus(-1, 0);
	}
	CallBackForMessageLoop pFunction = iter->second;
	if(pFunction != 0)
		return (m_pMessageOberver->*pFunction)(pMessage);
	else
		return CLStatus(-1,0);
}
开发者ID:ashimidashajia,项目名称:LibExcutor,代码行数:15,代码来源:CLMessageLoopManager.cpp

示例10: 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

示例11: Initialize

    virtual CLStatus Initialize(CLMessageLoopManager *pMessageLoop, void* pContext)
    {
        pMessageLoop->Register(1, (CallBackForMessageLoop)(&CLObserverTesterForCLMsgLoopManagerForShareNamedPipe::On_1));
        pMessageLoop->Register(2, (CallBackForMessageLoop)(&CLObserverTesterForCLMsgLoopManagerForShareNamedPipe::On_2));

        return CLStatus(0, 0);
    }
开发者ID:kekedan,项目名称:LibExecutive,代码行数:7,代码来源:CLMsgLoopManagerForShareNamedPipeTester.cpp

示例12: CLStatus

CLStatus CLConditionVariable::Wait(CLMutex *pMutex)
{
	if(pMutex == NULL)
		return CLStatus(-1, 0);
	
	int r = pthread_cond_wait(&m_ConditionVariable, pMutex->m_pMutex);
	if(r != 0)
	{
		CLLogger::WriteLogMsg("In CLConditionVariable::Wait, pthread_cond_wait error", r);
		return CLStatus(-1, 0);
	}
	else
	{
		return CLStatus(0, 0);
	}
}
开发者ID:unix1986,项目名称:universe,代码行数:16,代码来源:CLConditionVariable.cpp

示例13: On_2

	CLStatus On_2(CLMessage *pm)
	{
		CLMsg2ForCLNonThreadForMsgLoopTest *p = dynamic_cast<CLMsg2ForCLNonThreadForMsgLoopTest*>(pm);
		EXPECT_TRUE(p != 0);

		return CLStatus(QUIT_MESSAGE_LOOP, 0);
	}
开发者ID:ChengHuaUESTC,项目名称:LibExecutive,代码行数:7,代码来源:CLNonThreadForMsgLoopTester.cpp

示例14: CLRegularCoordinator

CLStatus CLThreadForMsgLoop::Ready(CLMessageObserver *pMsgObserver, const char *pstrThreadName,int ExecutiveType)
{
	m_pCoordinator = new CLRegularCoordinator();
	CLMessageLoopManager* pM;
	if(ExecutiveType == EXECUTIVE_IN_PROCESS_USE_STL_QUEUE)
	{
		pM = new CLMsgLoopManagerForSTLqueue(pMsgObserver,pstrThreadName);
	}
	else if(ExecutiveType == EXECUTIVE_IN_PROCESS_USE_PIPE_QUEUE)
	{
		m_pPipeMsgQueue = new CLMsgLoopManagerForPipeQueue(pMsgObserver,pstrThreadName,PIPE_QUEUE_IN_PROCESS);
		pM = m_pPipeMsgQueue;
	}
	else if(ExecutiveType == EXECUTIVE_BETWEEN_PROCESS_USE_PIPE_QUEUE)
	{
		m_pPipeMsgQueue = new CLMsgLoopManagerForPipeQueue(pMsgObserver,pstrThreadName,PIPE_QUEUE_BETWEEN_PROCESS);
		pM = m_pPipeMsgQueue;
	}
	else
		throw "In CLThreadForMsgLoop::Ready(), ExecutiveType error.";

	CLExecutiveFunctionForMsgLoop *myadder = new CLExecutiveFunctionForMsgLoop(pM);
	CLThread *pThread= new CLThread(m_pCoordinator, m_bWaitForDeath);
	m_pCoordinator->SetExecObjects(pThread,myadder);
	return CLStatus(0,0);
}
开发者ID:ashimidashajia,项目名称:LibExcutor,代码行数:26,代码来源:CLThreadForMsgLoop.cpp

示例15: CLStatus

CLStatus CLThread::WaitForDeath()
{
	if(!m_bThreadCreated)
		return CLStatus(-1,0);

	if(!m_bWaitForDeath)
		return CLStatus(-1,0);

	int r = pthread_join(m_ThreadID,0);
	if(0 != r){
		CLLogger::WriteLogMesg("In CLThread::WaitForDeath(), pthread_join error", r);
		return CLStatus(-1,0);
	}
	//delete this;
	return CLStatus(0,0);
}
开发者ID:ashimidashajia,项目名称:LibExcutor,代码行数:16,代码来源:CLThread.cpp


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