本文整理汇总了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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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 );
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例13: On_2
CLStatus On_2(CLMessage *pm)
{
CLMsg2ForCLNonThreadForMsgLoopTest *p = dynamic_cast<CLMsg2ForCLNonThreadForMsgLoopTest*>(pm);
EXPECT_TRUE(p != 0);
return CLStatus(QUIT_MESSAGE_LOOP, 0);
}
示例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);
}
示例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);
}