本文整理汇总了C++中MutexUnlock函数的典型用法代码示例。如果您正苦于以下问题:C++ MutexUnlock函数的具体用法?C++ MutexUnlock怎么用?C++ MutexUnlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MutexUnlock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GBASyncUnlockAudio
void GBASyncUnlockAudio(struct GBASync* sync) {
if (!sync) {
return;
}
MutexUnlock(&sync->audioBufferMutex);
}
开发者ID:netux79,项目名称:mgba,代码行数:7,代码来源:sync.c
示例2: MutexUnlock
void UvdState::unlock()
{
if (m_isRealtimeMode)
{
MutexUnlock(&m_lock);
}
}
开发者ID:rcg17,项目名称:uvdg-cocoa,代码行数:7,代码来源:UvdState.cpp
示例3: UsersDestroy
////////////////////////////////////////////////////////////
/// Destroy all users
////////////////////////////////////////////////////////////
bool UsersDestroy()
{
struct UserData * Iterator = UserList.First;
// Remove all users
while (Iterator != NULL)
{
struct UserData * TempUser = Iterator;
Iterator = Iterator->Next;
// Close the socket
MutexLock(&TempUser->MutexData);
SocketClose(&TempUser->Connection.Socket);
MutexUnlock(&TempUser->MutexData);
// Destroy the mutex
MutexDestroy(&TempUser->MutexData);
// Free it
free(TempUser);
TempUser = NULL;
}
return true;
}
开发者ID:jordanfin,项目名称:aoc,代码行数:32,代码来源:Users.c
示例4: HeapAllocate
void* HeapAllocate(MemAllocHeap* heap, size_t size)
{
bool thread_safe = 0 != (heap->m_Flags & HeapFlags::kThreadSafe);
if (thread_safe)
{
MutexLock(&heap->m_Lock);
}
void* ptr = nullptr;
#if ENABLED(USE_DLMALLOC)
ptr = mspace_malloc(heap->m_MemSpace, size);
#else
ptr = malloc(size);
#endif
if (!ptr)
{
Croak("out of memory allocating %d bytes", (int) size);
}
if (thread_safe)
{
MutexUnlock(&heap->m_Lock);
}
return ptr;
}
开发者ID:MadFishTheOne,项目名称:tundra,代码行数:27,代码来源:MemAllocHeap.cpp
示例5: HeapReallocate
void* HeapReallocate(MemAllocHeap *heap, void *ptr, size_t size)
{
bool thread_safe = 0 != (heap->m_Flags & HeapFlags::kThreadSafe);
if (thread_safe)
{
MutexLock(&heap->m_Lock);
}
void *new_ptr;
#if ENABLED(USE_DLMALLOC)
new_ptr = mspace_realloc(heap->m_MemSpace, ptr, size);
#else
new_ptr = realloc(ptr, size);
#endif
if (!new_ptr && size > 0)
{
Croak("out of memory reallocating %d bytes at %p", (int) size, ptr);
}
if (thread_safe)
{
MutexUnlock(&heap->m_Lock);
}
return new_ptr;
}
开发者ID:MadFishTheOne,项目名称:tundra,代码行数:27,代码来源:MemAllocHeap.cpp
示例6: MutexLock
MUTEX * avtExecutionManager::FindMutex( const MUTEX_ID id )
{
if (tPool == NULL)
return NULL;
std::map<MUTEX_ID, MUTEX *>::iterator it;
MUTEX *lock;
MutexLock( &mutexMapLock );
it = mutexMap.find( id );
if( it == mutexMap.end() )
{
// Not found, create it.
lock = new MUTEX;
MutexInit( lock );
mutexMap.insert( std::pair<MUTEX_ID, MUTEX *>(id, lock) );
}
else
{
lock = it->second;
}
MutexUnlock( &mutexMapLock );
return( lock );
}
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:28,代码来源:avtExecutionManager.C
示例7: MQTTDisconnect
int MQTTDisconnect(MQTTClient *c)
{
int rc = FAILURE;
Timer timer; // we might wait for incomplete incoming publishes to complete
int len = 0;
#if defined(MQTT_TASK)
MutexLock(&c->mutex);
#endif
TimerInit(&timer);
TimerCountdownMS(&timer, c->command_timeout_ms);
len = MQTTSerialize_disconnect(c->buf, c->buf_size);
if (len > 0) {
rc = sendPacket(c, len, &timer); // send the disconnect packet
}
MQTTCloseSession(c);
#if defined(MQTT_TASK)
MutexUnlock(&c->mutex);
#endif
return rc;
}
开发者ID:espressif,项目名称:ESP8266_RTOS_SDK,代码行数:25,代码来源:MQTTClient.c
示例8: BuildQueueDestroy
void BuildQueueDestroy(BuildQueue* queue)
{
Log(kDebug, "destroying build queue");
const BuildQueueConfig* config = &queue->m_Config;
MutexLock(&queue->m_Lock);
queue->m_QuitSignalled = true;
MutexUnlock(&queue->m_Lock);
CondBroadcast(&queue->m_WorkAvailable);
for (int i = 0, thread_count = config->m_ThreadCount; i < thread_count; ++i)
{
if (i > 0)
{
Log(kDebug, "joining with build thread %d", i);
ThreadJoin(queue->m_Threads[i]);
}
ThreadStateDestroy(&queue->m_ThreadState[i]);
}
// Deallocate storage.
MemAllocHeap* heap = queue->m_Config.m_Heap;
HeapFree(heap, queue->m_ExpensiveWaitList);
HeapFree(heap, queue->m_Queue);
CondDestroy(&queue->m_WorkAvailable);
MutexDestroy(&queue->m_Lock);
// Unblock all signals on the main thread.
SignalHandlerSetCondition(nullptr);
SignalBlockThread(false);
}
开发者ID:MadFishTheOne,项目名称:tundra,代码行数:34,代码来源:BuildQueue.cpp
示例9: _audioThread
static THREAD_ENTRY _audioThread(void* context) {
struct mPSP2AudioContext* audio = (struct mPSP2AudioContext*) context;
uint32_t zeroBuffer[PSP2_SAMPLES] = {0};
void* buffer = zeroBuffer;
int audioPort = sceAudioOutOpenPort(SCE_AUDIO_OUT_PORT_TYPE_MAIN, PSP2_SAMPLES, 48000, SCE_AUDIO_OUT_MODE_STEREO);
while (audio->running) {
MutexLock(&audio->mutex);
if (buffer != zeroBuffer) {
// Can only happen in successive iterations
audio->samples -= PSP2_SAMPLES;
ConditionWake(&audio->cond);
}
if (audio->samples >= PSP2_SAMPLES) {
buffer = &audio->buffer[audio->readOffset];
audio->readOffset += PSP2_SAMPLES;
if (audio->readOffset >= PSP2_AUDIO_BUFFER_SIZE) {
audio->readOffset = 0;
}
// Don't mark samples as read until the next loop iteration to prevent
// writing to the buffer while being read (see above)
} else {
buffer = zeroBuffer;
}
MutexUnlock(&audio->mutex);
sceAudioOutOutput(audioPort, buffer);
}
sceAudioOutReleasePort(audioPort);
return 0;
}
开发者ID:leiradel,项目名称:mgba,代码行数:30,代码来源:psp2-context.c
示例10: GBASyncWaitFrameEnd
void GBASyncWaitFrameEnd(struct GBASync* sync) {
if (!sync) {
return;
}
MutexUnlock(&sync->videoFrameMutex);
}
开发者ID:netux79,项目名称:mgba,代码行数:7,代码来源:sync.c
示例11: MutexUnlock
void avtExecutionManager::MutexUnlock( const MUTEX_ID stringID )
{
if (tPool == NULL)
return;
MutexUnlock( FindMutex(stringID) );
}
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:7,代码来源:avtExecutionManager.C
示例12: rwl_writer_stop
/**
* Call this function when a writer task finished using data that is
* protected by the given rwlock.
*/
void
rwl_writer_stop( TRWLock *rwlock )
{
rwlock->wcount--;
rwlock->wflag = 0;
MutexUnlock( rwlock->datalock );
}
开发者ID:LiberatorUSA,项目名称:GUCEF,代码行数:11,代码来源:gucefMT_DVRWLOCK.c
示例13: KLogToScreenDisable
void KLogToScreenDisable(void)
{
MutexLock (&dbg_mutex);
klog_to_screen = FALSE;
MutexUnlock (&dbg_mutex);
}
开发者ID:cod5,项目名称:kielder,代码行数:8,代码来源:kprintf.c
示例14: GBASyncConsumeAudio
void GBASyncConsumeAudio(struct GBASync* sync) {
if (!sync) {
return;
}
ConditionWake(&sync->audioRequiredCond);
MutexUnlock(&sync->audioBufferMutex);
}
开发者ID:netux79,项目名称:mgba,代码行数:8,代码来源:sync.c
示例15: GBASIOLockstepNodeUnload
bool GBASIOLockstepNodeUnload(struct GBASIODriver* driver) {
struct GBASIOLockstepNode* node = (struct GBASIOLockstepNode*) driver;
MutexLock(&node->p->mutex);
--node->p->loaded;
ConditionWake(&node->p->barrier);
MutexUnlock(&node->p->mutex);
return true;
}
开发者ID:joolswills,项目名称:mgba,代码行数:8,代码来源:lockstep.c
示例16: MutexUnlock
void *PoolAlloc(TPool *p,uint32 size)
{
TPoolZone *pz = 0;
TPoolZone *npz = 0;
void *x = 0;
uint32 zonesize = 0;
/* sanity */
if (!p || !size) {
return NULL;
}
if (!MutexLock(&p->mutex))
return NULL;
pz=p->currentzone;
if (pz->pos+size<pz->maxpos)
{
x=pz->pos;
pz->pos+=size;
MutexUnlock(&p->mutex);
return x;
};
if (size>p->zonesize)
zonesize=size;
else
zonesize=p->zonesize;
if( (npz = PoolZoneAlloc(zonesize)) )
{
npz->prev=pz;
npz->next=pz->next;
pz->next=npz;
p->currentzone=npz;
x=(void *)(npz+1);
npz->pos=((char *)(npz+1))+size;
}
else
x=NULL;
MutexUnlock(&p->mutex);
return x;
}
开发者ID:cmjonze,项目名称:anacapa,代码行数:45,代码来源:data.c
示例17: _changeVideoSync
static void _changeVideoSync(struct GBASync* sync, bool frameOn) {
// Make sure the video thread can process events while the GBA thread is paused
MutexLock(&sync->videoFrameMutex);
if (frameOn != sync->videoFrameOn) {
sync->videoFrameOn = frameOn;
ConditionWake(&sync->videoFrameAvailableCond);
}
MutexUnlock(&sync->videoFrameMutex);
}
开发者ID:netux79,项目名称:mgba,代码行数:9,代码来源:sync.c
示例18: GBASyncForceFrame
void GBASyncForceFrame(struct GBASync* sync) {
if (!sync) {
return;
}
MutexLock(&sync->videoFrameMutex);
ConditionWake(&sync->videoFrameAvailableCond);
MutexUnlock(&sync->videoFrameMutex);
}
开发者ID:netux79,项目名称:mgba,代码行数:9,代码来源:sync.c
示例19: main
int main()
{
TThread loggingThread;
TThread *loggerThreads = (TThread*)malloc(sizeof(TThread) * numThreadsToStart);
unsigned int i = 0;
printf("Creating threads\n");
/* fire off the consumer thread */
ThreadCreate(&loggingThread, log_error_thread, 0);
sleep(1);
/* fire off the producer threads */
for (i=0; i<numThreadsToStart; ++i) {
int *thrNum = (int*)malloc(sizeof(int));
*thrNum = i;
ThreadCreate(&loggerThreads[i], testLoggingThread, thrNum);
}
sleep(1);
printf("Signalling START\n");
/* signal that the threads can start */
MutexLock(&cond_mutex);
start_flag = 1;
CondBroadcast(&start_cond);
MutexUnlock(&cond_mutex);
printf("Waiting for threads to complete\n");
MutexLock(&threadCountLock);
while (threadCount) {
CondWait(&threadCountCond, &threadCountLock);
}
MutexUnlock(&threadCountLock);
sleep(10);
printf("See ya later, alligator\n");
return EXIT_SUCCESS;
}
开发者ID:cmjonze,项目名称:anacapa,代码行数:44,代码来源:t_ap_log.c
示例20: networkThread
ThreadFunc networkThread(void *) {
while (true) {
MutexLock(mutex);
if (!threadRun) {
MutexUnlock(mutex);
break;
}
if (reqs.empty()) {
MutexUnlock(mutex);
continue;
}
Request& r = reqs.front();
//if (r._signal == PLAYER_PACKET_SEND && ((PlayerPacket*)r._dataSend)->onlineID != player::onlineID)
// cout << "[ERROR]WTF!!!" << endl;
if (r._dataSend != nullptr && r._dataLen != 0) {
Net::Buffer buffer(r._dataLen + sizeof(int) * 2);
int len = r._dataLen + sizeof(int);
buffer.write((void*)&len, sizeof(int));
buffer.write((void*)&r._signal, sizeof(int));
buffer.write((void*)r._dataSend, r._dataLen);
getClientSocket().send(buffer);
}
else {
Net::Buffer buffer(sizeof(int) * 2);
int len = sizeof(int);
buffer.write((void*)&len, sizeof(int));
buffer.write((void*)&r._signal, sizeof(int));
getClientSocket().send(buffer);
}
if (r._callback) { //判断有无回调函数
auto callback = r._callback;
MutexUnlock(mutex);
int len = getClientSocket().recvInt(); //获得数据长度
Net::Buffer buffer(len);
getClientSocket().recv(buffer, Net::BufferConditionExactLength(len));
if (len > 0) callback(buffer.getData(), len); //调用回调函数
MutexLock(mutex);
}
reqs.pop();
MutexUnlock(mutex);
}
return 0;
}
开发者ID:435886030,项目名称:NEWorld,代码行数:43,代码来源:Network.cpp
注:本文中的MutexUnlock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论