您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ unlockMutex函数代码示例

51自学网 2021-06-03 09:10:54
  C++
这篇教程C++ unlockMutex函数代码示例写得很实用,希望能帮到您。

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

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

示例1: lockMutex

bool SendFileStraight::send() {	if (m_stream->isOpen()){		lockMutex();		std::string data;		int size = m_parent->getDataToSend(data);		if (size != 0) {			int ret = m_stream->send(data);			if (ret < 1) {				std::cout << "error in sending or sending probably finished/n";				unlockMutex();				return false;			};		}		else			wait();		unlockMutex();	}	else {		std::cout << "stream not open!/n";		g_usleep(G_USEC_PER_SEC);	}	if (m_stream->recv(2000) != ConnNoError) {		m_parent->tryToDeleteMe();// 		g_timeout_add(0, &try_to_delete_me, m_parent);		return false;	}	if (shouldStop()) {		Log("SendFileStraight", "stopping thread");		return false;	}		return true;}
开发者ID:bochi,项目名称:spectrum-gw,代码行数:33,


示例2: lockMutex

voidArchMultithreadWindows::doThreadFunc(ArchThread thread){    // wait for parent to initialize this object    lockMutex(m_threadMutex);    unlockMutex(m_threadMutex);    void* result = NULL;    try {        // go        result = (*thread->m_func)(thread->m_userData);    }    catch (XThreadCancel&) {        // client called cancel()    }    catch (...) {        // note -- don't catch (...) to avoid masking bugs        SetEvent(thread->m_exit);        closeThread(thread);        throw;    }    // thread has exited    lockMutex(m_threadMutex);    thread->m_result = result;    unlockMutex(m_threadMutex);    SetEvent(thread->m_exit);    // done with thread    closeThread(thread);}
开发者ID:digitalmystic,项目名称:synergy,代码行数:32,


示例3: AutoFreePool_addCallback

void AutoFreePool_addCallback(void (* callback)(void * context), void * context) {    if (mutex != NULL) {        lockMutex(mutex);    }    if (poolStackDepth == -1) {        if (mutex != NULL) {            unlockMutex(mutex);        }        AutoFreePool_push();        if (mutex != NULL) {            lockMutex(mutex);        }    }    if (poolStack[poolStackDepth].callbacks == NULL) {        poolStack[poolStackDepth].numberOfCallbacks = 0;        poolStack[poolStackDepth].callbackListSize = 1;        poolStack[poolStackDepth].callbacks = malloc(sizeof(struct AutoFreePool_callback) * poolStack[poolStackDepth].callbackListSize);    } else if (poolStack[poolStackDepth].numberOfCallbacks >= poolStack[poolStackDepth].callbackListSize) {        poolStack[poolStackDepth].callbackListSize *= 2;        poolStack[poolStackDepth].callbacks = realloc(poolStack[poolStackDepth].callbacks, sizeof(struct AutoFreePool_callback) * poolStack[poolStackDepth].callbackListSize);    }    poolStack[poolStackDepth].callbacks[poolStack[poolStackDepth].numberOfCallbacks].callback = callback;    poolStack[poolStackDepth].callbacks[poolStack[poolStackDepth].numberOfCallbacks].context = context;    poolStack[poolStackDepth].numberOfCallbacks++;    if (mutex != NULL) {        unlockMutex(mutex);    }}
开发者ID:svn2github,项目名称:libstem,代码行数:32,


示例4: lockMutex

VPLTHREAD_FN_DECL AsyncServiceClientStateImpl::doRpc(void* arg){    AsyncServiceClientState* clientState = (AsyncServiceClientState*)arg;    // Lock sendRequestMutex before dequeuing, to ensure that we send the    // request messages in the same order that they were enqueued.    lockMutex(&clientState->pImpl->sendRequestMutex);    AsyncCallState* callState = clientState->pImpl->requests.dequeue(true);    if (callState == NULL) {        unlockMutex(&clientState->pImpl->sendRequestMutex);        // TODO: assert failed!    } else {        ProtoRpcClient* tempClient = callState->asyncClient->_acquireClientCallback();        if (tempClient == NULL) {            unlockMutex(&clientState->pImpl->sendRequestMutex);            callState->status.set_status(RpcStatus_Status_INTERNAL_ERROR);            callState->status.set_errordetail("Failed to acquire ProtoRpcClient");        } else {            // Must call this with sendRequestMutex held.            bool sendSuccess = callState->sendRpcRequest(*tempClient);            // Request message sent; we can release the lock now.            unlockMutex(&clientState->pImpl->sendRequestMutex);            if (sendSuccess) {                callState->recvRpcResponse(*tempClient);            }            callState->asyncClient->_releaseClientCallback(tempClient);        }        clientState->pImpl->results.enqueue(callState);    }    return VPLTHREAD_RETURN_VALUE;}
开发者ID:iversonjimmy,项目名称:acer_cloud_wifi_copy,代码行数:30,


示例5: AutoFreePool_empty

void AutoFreePool_empty() {    if (mutex != NULL) {        lockMutex(mutex);    }    if (poolStackDepth == -1) {        if (mutex != NULL) {            unlockMutex(mutex);        }        return;    }    if (poolStack[poolStackDepth].addresses != NULL) {        unsigned int addressIndex;        for (addressIndex = 0; addressIndex < poolStack[poolStackDepth].numberOfAddresses; addressIndex++) {            free(poolStack[poolStackDepth].addresses[addressIndex]);        }        poolStack[poolStackDepth].numberOfAddresses = 0;    }    if (poolStack[poolStackDepth].callbacks != NULL) {        unsigned int callbackIndex;        for (callbackIndex = 0; callbackIndex < poolStack[poolStackDepth].numberOfCallbacks; callbackIndex++) {            poolStack[poolStackDepth].callbacks[callbackIndex].callback(poolStack[poolStackDepth].callbacks[callbackIndex].context);        }        poolStack[poolStackDepth].numberOfCallbacks = 0;    }    if (mutex != NULL) {        unlockMutex(mutex);    }}
开发者ID:svn2github,项目名称:libstem,代码行数:33,


示例6: AutoFreePool_add

void * AutoFreePool_add(void * address) {    if (mutex != NULL) {        lockMutex(mutex);    }    if (poolStackDepth == -1) {        if (mutex != NULL) {            unlockMutex(mutex);        }        AutoFreePool_push();        if (mutex != NULL) {            lockMutex(mutex);        }    }    if (poolStack[poolStackDepth].addresses == NULL) {        poolStack[poolStackDepth].numberOfAddresses = 0;        poolStack[poolStackDepth].addressListSize = 1;        poolStack[poolStackDepth].addresses = malloc(sizeof(void *) * poolStack[poolStackDepth].addressListSize);    } else if (poolStack[poolStackDepth].numberOfAddresses >= poolStack[poolStackDepth].addressListSize) {        poolStack[poolStackDepth].addressListSize *= 2;        poolStack[poolStackDepth].addresses = realloc(poolStack[poolStackDepth].addresses, sizeof(void *) * poolStack[poolStackDepth].addressListSize);    }    poolStack[poolStackDepth].addresses[poolStack[poolStackDepth].numberOfAddresses++] = address;    if (mutex != NULL) {        unlockMutex(mutex);    }    return address;}
开发者ID:svn2github,项目名称:libstem,代码行数:32,


示例7: getCancelEventForCurrentThread

boolArchMultithreadWindows::waitCondVar(ArchCond cond,                            ArchMutex mutex, double timeout){    // prepare to wait    const DWORD winTimeout = (timeout < 0.0) ? INFINITE :                                static_cast<DWORD>(1000.0 * timeout);    // make a list of the condition variable events and the cancel event    // for the current thread.    HANDLE handles[4];    handles[0] = cond->m_events[ArchCondImpl::kSignal];    handles[1] = cond->m_events[ArchCondImpl::kBroadcast];    handles[2] = getCancelEventForCurrentThread();    // update waiter count    lockMutex(cond->m_waitCountMutex);    ++cond->m_waitCount;    unlockMutex(cond->m_waitCountMutex);    // release mutex.  this should be atomic with the wait so that it's    // impossible for another thread to signal us between the unlock and    // the wait, which would lead to a lost signal on broadcasts.    // however, we're using a manual reset event for broadcasts which    // stays set until we reset it, so we don't lose the broadcast.    unlockMutex(mutex);    // wait for a signal or broadcast    DWORD result = WaitForMultipleObjects(3, handles, FALSE, winTimeout);    // cancel takes priority    if (result != WAIT_OBJECT_0 + 2 &&        WaitForSingleObject(handles[2], 0) == WAIT_OBJECT_0) {        result = WAIT_OBJECT_0 + 2;    }    // update the waiter count and check if we're the last waiter    lockMutex(cond->m_waitCountMutex);    --cond->m_waitCount;    const bool last = (result == WAIT_OBJECT_0 + 1 && cond->m_waitCount == 0);    unlockMutex(cond->m_waitCountMutex);    // reset the broadcast event if we're the last waiter    if (last) {        ResetEvent(cond->m_events[ArchCondImpl::kBroadcast]);    }    // reacquire the mutex    lockMutex(mutex);    // cancel thread if necessary    if (result == WAIT_OBJECT_0 + 2) {        ARCH->testCancelThread();    }    // return success or failure    return (result == WAIT_OBJECT_0 + 0 ||            result == WAIT_OBJECT_0 + 1);}
开发者ID:digitalmystic,项目名称:synergy,代码行数:59,


示例8: assert

boolArchMultithreadPosix::wait(ArchThread target, double timeout){	assert(target != NULL);	lockMutex(m_threadMutex);	// find current thread	ArchThreadImpl* self = findNoRef(pthread_self());	// ignore wait if trying to wait on ourself	if (target == self) {		unlockMutex(m_threadMutex);		return false;	}	// ref the target so it can't go away while we're watching it	refThread(target);	unlockMutex(m_threadMutex);	try {		// do first test regardless of timeout		testCancelThreadImpl(self);		if (isExitedThread(target)) {			closeThread(target);			return true;		}		// wait and repeat test if there's a timeout		if (timeout != 0.0) {			const double start = ARCH->time();			do {				// wait a little				ARCH->sleep(0.05);				// repeat test				testCancelThreadImpl(self);				if (isExitedThread(target)) {					closeThread(target);					return true;				}				// repeat wait and test until timed out			} while (timeout < 0.0 || (ARCH->time() - start) <= timeout);		}		closeThread(target);		return false;	}	catch (...) {		closeThread(target);		throw;	}}
开发者ID:Coolred,项目名称:synergy,代码行数:55,


示例9: queue_get

int queue_get(queue_t*queue, void*data){    lockMutex(&queue->mutex);    if(queue->writepos == queue->readpos) {	unlockMutex(&queue->mutex);	return 0;    }    memcpy(data, &queue->data[queue->readpos*queue->size], queue->size);    queue->readpos++;    queue->readpos %= queue->nmemb;    queue->number--;    unlockMutex(&queue->mutex);    return 1;}
开发者ID:DJwa163,项目名称:swftools,代码行数:14,


示例10: connectionAddListener

PAPIListenerId connectionAddListener( PAPIConnection *	inConnection,									  const char *		inComponentName,									  PAPIListener		inListener,									  void *			inUserData,									  PAPIStatus *		outStatus ){	PAPIListenerId theListenerId	= 0;	*outStatus			= PAPISuccess;	if ( lockMutex( inConnection->mListenersMutex ) == 0 )	{		theListenerId = addListenerList( &( inConnection->mListeners ),						inComponentName,						inListener,						inUserData );		*outStatus = theListenerId == 0 ?							PAPIOutOfMemoryFailure :							PAPISuccess;		unlockMutex( inConnection->mListenersMutex );	}	else	{		*outStatus = PAPIUnknownFailure;	}	return theListenerId;}
开发者ID:freedesktop-unofficial-mirror,项目名称:apoc-agent,代码行数:25,


示例11: lockMutex

bool VideoImpl::seekTo(guint64 positionNanoSeconds){  if (!_appsink0 || !_seekEnabled)  {    return false;  }  else  {    lockMutex();    // Free the current sample and reset.    _freeCurrentSample();    _bitsChanged = false;    // Seek to position.    bool result = gst_element_seek_simple(                    _appsink0, GST_FORMAT_TIME,                    GstSeekFlags( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE ),                    positionNanoSeconds);    unlockMutex();    return result;  }}
开发者ID:mapmapteam,项目名称:mapmap,代码行数:25,


示例12: feedbackLibrary

int feedbackLibrary(char *name, int preload){	struct section_file_data *sfd;	int retval = 0;	if( !kaffe_feedback_file )		return( 0 );	lockMutex(kaffe_feedback_file);	if( !(sfd = findSectionInFile(kaffe_feedback_file,				      &lib_section, name)) )	{		/*		 * If the section doesn't exist we need to create and add it.		 * We only set preload here since the user might've changed		 * the file to specify otherwise.		 */		if( (sfd = createFileSection(lib_section.fs_name, name,					     "preload", preload ?					     "true" : "false",					     NULL)) )		{			addSectionToFile(kaffe_feedback_file, sfd);			retval = 1;		}	}	else		retval = 1;	unlockMutex(kaffe_feedback_file);	return( retval );}
开发者ID:jameshilliard,项目名称:actiontec_opensrc_mi424wr-rev-e-f_fw-20-10-7-5,代码行数:30,


示例13: writePipe

int writePipe(pipe_t pipe,char* msg, uint64_t amount){    int i;    lockMutex(pipe->writeMutex);    while (pipe->bufferSize >= MINPAGE){        waitCondVar(&pipe->writeCondVar,pipe->writeMutex);    }    lockMutex(pipe->mutex);    for(i=0;i<amount;i++){        pipe->buffer[(pipe->initialIndex + pipe->bufferSize) %MINPAGE]=msg[i];        pipe->bufferSize ++;    }    signalCondVar(&pipe->readCondVar);    unlockMutex(pipe->mutex);    unlockMutex(pipe->writeMutex);    return 1;}
开发者ID:jcaracciolo,项目名称:Arqui2016,代码行数:16,


示例14: VPLSem_Wait

AsyncCallState* MyQueue::dequeue(bool blockIfEmpty){    int sem_rv;    if (blockIfEmpty) {        sem_rv = VPLSem_Wait(&queueSem);    } else {        sem_rv = VPLSem_TryWait(&queueSem);    }    if (sem_rv == 0) {        AsyncCallState* result;        lockMutex(&queueMutex);        if (head == NULL) {            result = NULL;        } else {            result = head;            head = result->nextInQueue;            if (head == NULL) {                tail = NULL;            }            result->nextInQueue = NULL;        }        unlockMutex(&queueMutex);        return result;    } else {        return NULL;    }}
开发者ID:iversonjimmy,项目名称:acer_cloud_wifi_copy,代码行数:27,


示例15: closePipe

int closePipe(int pipe){    Spipe *p = checkSpipeData(pipe);    if(!p)        return -1;    int pid = getpid();    enterProcessCriticalCode(pid);    // лочим мютекс, блокируем io операции над пайпом    lockMutex(&p->locker);    free(p->memory);    p->memory = 0;    destroyWaitCond(p->ready_read_wid);    destroyWaitCond(p->ready_write_wid);    destroyWaitCond(p->fully_flushed_wid);    destroyWaitCond(p->fully_empty_wid);    unlockMutex(&p->locker);    destroyMutex(&p->locker);    freeSpipeData(p->id);    leaveProcessCriticalCode(pid);    return 0;}
开发者ID:DemonSinusa,项目名称:SiemanC,代码行数:26,


示例16: lockMutex

void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect){	lockMutex();	if (!this->m_iirgaus) {		MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputprogram->initializeTileData(rect);		MemoryBuffer *copy = newBuf->duplicate();		FastGaussianBlurOperation::IIR_gauss(copy, this->m_sigma, 0, 3);		if (this->m_overlay == FAST_GAUSS_OVERLAY_MIN) {			float *src = newBuf->getBuffer();			float *dst = copy->getBuffer();			for (int i = copy->getWidth() * copy->getHeight(); i != 0; i--, src += COM_NUM_CHANNELS_VALUE, dst += COM_NUM_CHANNELS_VALUE) {				if (*src < *dst) {					*dst = *src;				}			}		}		else if (this->m_overlay == FAST_GAUSS_OVERLAY_MAX) {			float *src = newBuf->getBuffer();			float *dst = copy->getBuffer();			for (int i = copy->getWidth() * copy->getHeight(); i != 0; i--, src += COM_NUM_CHANNELS_VALUE, dst += COM_NUM_CHANNELS_VALUE) {				if (*src > *dst) {					*dst = *src;				}			}		}//		newBuf->		this->m_iirgaus = copy;	}	unlockMutex();	return this->m_iirgaus;}
开发者ID:wchargin,项目名称:blender,代码行数:34,


示例17: lockMutex

void SQLMXLoggingArea::logPOSErrorEvent(const Lng32 errorCode,                                        const char *msg1,                                        const char *msg2,                                        const char *msg3){  bool lockedMutex = lockMutex();  SqlSealogEvent sevent;  // Open a  new connection   sevent.openConnection();  // set the required parameters  sevent.setError1(errorCode);  sevent.setString0((char *)msg1);  sevent.setString1((char *)msg2);  sevent.setString2((char *)msg3);   // set the event id and severity and send the event  if (errorCode == 1150)    sevent.sendEvent(SQEV_SQL_POS_ERROR, SQ_LOG_ERR);  else if (errorCode ==1154)    sevent.sendEvent(SQEV_SQL_POS_CREATE_ERROR,SQ_LOG_ERR);  // close the connection.  sevent.closeConnection();   if (lockedMutex)    unlockMutex();	}
开发者ID:ryzuo,项目名称:incubator-trafodion,代码行数:26,


示例18: lockMutex

void *PlaneCornerPinWarpImageOperation::initializeTileData(rcti *rect){  void *data = PlaneDistortWarpImageOperation::initializeTileData(rect);  /* get corner values once, by reading inputs at (0,0)   * XXX this assumes invariable values (no image inputs),   * we don't have a nice generic system for that yet   */  lockMutex();  if (!m_corners_ready) {    /* corner sockets start at index 1 */    SocketReader *readers[4] = {        getInputSocketReader(1),        getInputSocketReader(2),        getInputSocketReader(3),        getInputSocketReader(4),    };    float corners[4][2];    readCornersFromSockets(rect, readers, corners);    calculateCorners(corners, true, 0);    m_corners_ready = true;  }  unlockMutex();  return data;}
开发者ID:dfelinto,项目名称:blender,代码行数:27,


示例19: queue_put

int queue_put(queue_t*queue, void*data){    int tmp = queue->writepos+1;    tmp%=queue->nmemb;    lockMutex(&queue->mutex);    if(tmp==queue->readpos) {	unlockMutex(&queue->mutex);	return 0;    }    memcpy(&queue->data[queue->writepos*queue->size], data, queue->size);    queue->writepos = tmp;    queue->number++;    unlockMutex(&queue->mutex);    return 1;}
开发者ID:DJwa163,项目名称:swftools,代码行数:16,


示例20: queue_flush

void queue_flush(queue_t*queue){    lockMutex(&queue->mutex);    queue->number = 0;    queue->readpos = 0;    queue->writepos = 0;    unlockMutex(&queue->mutex);}
开发者ID:DJwa163,项目名称:swftools,代码行数:8,


示例21: lockMutex

boolArchMultithreadPosix::isExitedThread(ArchThread thread){	lockMutex(m_threadMutex);	bool exited = thread->m_exited;	unlockMutex(m_threadMutex);	return exited;}
开发者ID:Coolred,项目名称:synergy,代码行数:8,


示例22: lockMutex

void*CArchMultithreadPosix::getNetworkDataForThread(CArchThread thread){	lockMutex(m_threadMutex);	void* data = thread->m_networkData;	unlockMutex(m_threadMutex);	return data;}
开发者ID:BogdanLivadariu,项目名称:synergy,代码行数:8,



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


C++ unlock_dir函数代码示例
C++ unlockBuffer函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。