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


C++ MUTEX_UNLOCK函数代码示例

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


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

示例1: iqueue_pop

void iqueue_pop(void *queue, int *data)
{
    QUEUE *q = (QUEUE *)queue;
    QNODE *node = NULL;

    if(q)
    {
        MUTEX_LOCK(q->mutex);
        if((node = q->first))
        {
            *data = node->data;
            if((q->first = q->first->next) == NULL)
            {
                q->last = NULL;
            }
            node->next = q->left;
            q->left = node;
            --(q->total);
        }
        MUTEX_UNLOCK(q->mutex);
    } 
    return ;
}
开发者ID:cnangel,项目名称:hidbase,代码行数:23,代码来源:iqueue.c

示例2: obj_context_has_popups

/* search the list of all policies bound to context @tspContext. If
 * one is found of type popup, return TRUE, else return FALSE. */
TSS_BOOL
obj_context_has_popups(TSS_HCONTEXT tspContext)
{
    struct tsp_object *obj;
    struct tr_policy_obj *policy;
    struct obj_list *list = &policy_list;
    TSS_BOOL ret = FALSE;

    MUTEX_LOCK(list->lock);

    for (obj = list->head; obj; obj = obj->next) {
        if (obj->tspContext == tspContext) {
            policy = (struct tr_policy_obj *)obj->data;
            if (policy->SecretMode == TSS_SECRET_MODE_POPUP)
                ret = TRUE;
            break;
        }
    }

    MUTEX_UNLOCK(list->lock);

    return ret;
}
开发者ID:randombit,项目名称:hacrypto,代码行数:25,代码来源:obj_context.c

示例3: Dart_UpdateBuffers

/* Buffer update thread (created and called by DART)
   This is a high-priority thread used to compute and update the audio stream,
   automatically created by the DART subsystem. We compute the next audio
   buffer and feed it to the waveaudio device. */
static LONG APIENTRY Dart_UpdateBuffers(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, ULONG ulFlags)
{
	/* sanity check */
	if (!pBuffer)
		return TRUE;
	
	/* if we have finished a buffer, we're ready to play a new one */
	if ((ulFlags == MIX_WRITE_COMPLETE) ||
		((ulFlags == (MIX_WRITE_COMPLETE | MIX_STREAM_ERROR)) &&
		 (ulStatus == ERROR_DEVICE_UNDERRUN))) {
		/* refill this audio buffer and feed it again */
		MUTEX_LOCK(vars);
		if (Player_Paused_internal())
			pBuffer->ulBufferLength =
					VC_SilenceBytes(pBuffer->pBuffer, BufferSize);
		else
			pBuffer->ulBufferLength =
					VC_WriteBytes(pBuffer->pBuffer, BufferSize);
		MUTEX_UNLOCK(vars);
		MixSetupParms.pmixWrite(MixSetupParms.ulMixHandle, pBuffer, 1);
	}
	return TRUE;
}
开发者ID:fruitz-of-dojo,项目名称:libmikmod,代码行数:27,代码来源:drv_dart.c

示例4: mailstream_ssl_init

static inline void mailstream_ssl_init(void)
{
#ifdef USE_SSL
    mailstream_ssl_init_lock();
    MUTEX_LOCK(&ssl_lock);
#ifndef USE_GNUTLS
    if (!openssl_init_done) {
#if defined (HAVE_PTHREAD_H) && !defined (WIN32) && defined (USE_SSL) && defined (LIBETPAN_REENTRANT)
        mailstream_openssl_reentrant_setup();
#endif

        SSL_load_error_strings();
        SSL_library_init();
        OpenSSL_add_all_algorithms();

        openssl_init_done = 1;
    }
#else
    gnutls_global_init();
#endif
    MUTEX_UNLOCK(&ssl_lock);
#endif
}
开发者ID:pgeof,项目名称:libetpan,代码行数:23,代码来源:mailstream_ssl.c

示例5: mmtree64_qleft

//add nodeid to qleft
void mmtree64_qleft(void *x, int tnodeid)
{
    int z = 0;
    if(x)
    {
        MUTEX_LOCK(MMT(x)->mutex);
        memset(&(MMT(x)->map[tnodeid]), 0, sizeof(MTNODE64));
        if(MMT(x)->state->qleft == 0)
        {
            MMT(x)->state->qfirst = MMT(x)->state->qlast = tnodeid;
        }
        else
        {
            z = MMT(x)->state->qlast;
            MMT(x)->map[z].parent = tnodeid;
            MMT(x)->state->qlast = tnodeid;
        }
        MMT(x)->state->qleft++;
        MMT(x)->state->left++;
        MUTEX_UNLOCK(MMT(x)->mutex);
    }
    return ;
}
开发者ID:cnangel,项目名称:hidbase,代码行数:24,代码来源:mmtree64.c

示例6: mmqueue_pop

/* pop */
int mmqueue_pop(MMQUEUE *mmq, int rootid, int64_t *data)
{
    int id = -1;

    if(mmq && rootid > 0 && rootid < MMQ_ROOT_MAX)
    {
        MUTEX_LOCK(mmq->mutex);
        if(mmq->state && mmq->nodes && mmq->state->roots[rootid].status > 0 
                && mmq->state->roots[rootid].total > 0 
                && (id = mmq->state->roots[rootid].first) > 0)
        {
            if(data) *data = mmq->nodes[id].data;    
            mmq->state->roots[rootid].first = mmq->nodes[id].next;
            mmq->state->roots[rootid].total--;
            if(mmq->state->roots[rootid].total == 0)
                mmq->state->roots[rootid].last = 0;
            mmq->nodes[id].next = mmq->state->qleft;
            mmq->state->qleft = id;
        }
        MUTEX_UNLOCK(mmq->mutex);
    }
    return id;
}
开发者ID:cnangel,项目名称:ithunder,代码行数:24,代码来源:mmqueue64.c

示例7: MikMod_InfoDriver

MIKMODAPI CHAR* MikMod_InfoDriver(void)
{
	int t;
	size_t len=0;
	MDRIVER *l;
	CHAR *list=NULL;

	MUTEX_LOCK(lists);
	/* compute size of buffer */
	for(l=firstdriver;l;l=l->next)
		len+=4+(l->next?1:0)+strlen(l->Version);

	if(len)
		if((list=MikMod_malloc(len*sizeof(CHAR)))) {
			list[0]=0;
			/* list all registered device drivers : */
			for(t=1,l=firstdriver;l;l=l->next,t++)
				sprintf(list,(l->next)?"%s%2d %s\n":"%s%2d %s",
				    list,t,l->Version);
		}
	MUTEX_UNLOCK(lists);
	return list;
}
开发者ID:mistydemeo,项目名称:libmikmod,代码行数:23,代码来源:mdriver.c

示例8: validate_stream_params

static int validate_stream_params(struct cli_state *s, struct rxtx_data *rxtx,
                                  const char *argv0)
{
    int status = 0;
    MUTEX_LOCK(&rxtx->data_mgmt.lock);

    /* These items will have been checked when the parameter was set */
    assert(rxtx->data_mgmt.samples_per_buffer >= RXTX_SAMPLES_MIN);
    assert(rxtx->data_mgmt.samples_per_buffer % RXTX_SAMPLES_MIN == 0);
    assert(rxtx->data_mgmt.num_buffers >= RXTX_BUFFERS_MIN);

    if (rxtx->data_mgmt.num_transfers >= rxtx->data_mgmt.num_buffers) {
        cli_err(s, argv0,
                "The 'xfers' parameter (%u) must be < the 'buffers'"
                " parameter (%u).\n", rxtx->data_mgmt.num_transfers,
                rxtx->data_mgmt.num_buffers);

        status = CLI_RET_INVPARAM;
    }

    MUTEX_UNLOCK(&rxtx->data_mgmt.lock);
    return status;
};
开发者ID:HKingz,项目名称:bladeRF,代码行数:23,代码来源:rxtx.c

示例9: JKG_Assert

asyncTask_t *JKG_Stack_Pop(jkg_stack_t *stack)
{
	asyncTask_t *task;

	// FIXME
	/*if(!stack && !stack->init)
	{
		return;
	}*/

	JKG_Assert(stack);
	JKG_Assert(stack->init);
	MUTEX_LOCK(stack);
	
	task = stack->head;			// Get the head item
	if (task) {					// If it's not NULL, there was an item
		stack->head = stack->head->next;	// Update the head item
		task->next = NULL;
		UNFLAGTASK(task);		// Unflag the task (debug only)
	}
	MUTEX_UNLOCK(stack);		// Unlock the mutex/CS
	return task;
}
开发者ID:NikitaRus,项目名称:JediKnightGalaxies-1,代码行数:23,代码来源:jkg_threadingsq.cpp

示例10: MUTEX_LOCK

long eprom24x_core::update_error(eprom24x_exception rxp)
{
  MUTEX_LOCK(m_error_mutex);
  if (m_last_error_read) {
    m_error_source    = rxp.get_source();
    m_error_code      = rxp.get_code();
    m_last_error_read = false; // Latch last error until read
  }
  MUTEX_UNLOCK(m_error_mutex);

#ifdef DEBUG_PRINTS 
  switch(rxp.get_source()) {
  case EPROM24x_INTERNAL_ERROR:
    debug_internal_error();
    break;
  case EPROM24x_LINUX_ERROR:
    debug_linux_error();
    break;
  }
#endif

  return EPROM24x_FAILURE;
}
开发者ID:emwhbr,项目名称:rpi,代码行数:23,代码来源:eprom24x_core.cpp

示例11: bytes2buf

void bytes2buf(void *dest, size_t done, buf_str *ctx) {
	size_t len;
	//FIXME if (done & 3)
	if (ctx->to <= done) { done = ctx->to; ctx->to = 0; }
	else { ctx->to -= done; }
	if (ctx->from >= done) { ctx->from -= done; return; }
	else if (ctx->from > 0) { done -= ctx->from; dest += ctx->from; ctx->from = 0; }
	while (done) {
		len = (ctx->p.period - ctx->cur_period) * CHANNELS * BITS / 8;
		if (len > done) len = done;
		memcpy(ctx->p.buf + (ctx->cur_id * ctx->p.period + ctx->cur_period) * CHANNELS * BITS / 8, dest, len);
		done -= len;
		dest += len;
		ctx->cur_period += len / (CHANNELS * BITS / 8);
		if (ctx->cur_period >= ctx->p.period) {
			ctx->cur_id++;
			ctx->cur_id = ctx->cur_id & ctx->p.buf_max;
			MUTEX_LOCK(ctx->p.mutex + ctx->cur_id);
			MUTEX_UNLOCK(ctx->p.mutex + ((ctx->cur_id - 1) & ctx->p.buf_max));
			ctx->cur_period = 0;
		}
	}
}
开发者ID:yogpstop,项目名称:MyGCCProj,代码行数:23,代码来源:buffer.c

示例12: remove_table_entry

void
remove_table_entry(TSS_HCONTEXT tspContext)
{
	struct host_table_entry *hte, *prev = NULL;

	MUTEX_LOCK(ht->lock);

	for (hte = ht->entries; hte; prev = hte, hte = hte->next) {
		if (hte->tspContext == tspContext) {
			if (prev != NULL)
				prev->next = hte->next;
			else
				ht->entries = hte->next;
			if (hte->hostname)
				free(hte->hostname);
			free(hte->comm.buf);
			free(hte);
			break;
		}
	}

	MUTEX_UNLOCK(ht->lock);
}
开发者ID:IIJ-NetBSD,项目名称:netbsd-src,代码行数:23,代码来源:hosttable.c

示例13: XAudio2_Exit

static void XAudio2_Exit(void) {
	if (UpdateBufferHandle != NULL) {
		/* signal thread to exit and wait for the exit */
		if (threadInUse) {
			threadInUse = 0;
			MUTEX_UNLOCK(vars);
			SetEvent(hBufferEvent);
			WaitForSingleObject(UpdateBufferHandle, INFINITE);
			MUTEX_LOCK(vars);
		}
		CloseHandle(UpdateBufferHandle);
		UpdateBufferHandle = NULL;
	}
	IXAudio2SourceVoice_Stop(pSourceVoice, 0, 0);
	if (pSourceVoice) {
		IXAudio2SourceVoice_DestroyVoice(pSourceVoice);
		pSourceVoice = NULL;
	}
	if (pMasterVoice) {
		IXAudio2MasteringVoice_DestroyVoice(pMasterVoice);
		pMasterVoice = NULL;
	}
	if (pXAudio2) {
		IXAudio2_Release(pXAudio2);
		pXAudio2 = NULL;
	}
#ifndef __cplusplus
	if (hBufferEvent != NULL) {
		CloseHandle(hBufferEvent);
		hBufferEvent = NULL;
	}
#endif
#ifndef _XBOX
	CoUninitialize();
#endif
	VC_Exit();
}
开发者ID:OS2World,项目名称:LIB-SDL-2014,代码行数:37,代码来源:drv_xaudio2.c

示例14: USBDevice_Write

int 
USBDevice_Write(LPSKYETEK_DEVICE device,
		unsigned char* buffer,
		unsigned int length,
    unsigned int timeout)
{
	unsigned char* ptr;
	unsigned char writeSize;
	LPUSB_DEVICE usbDevice;
	
	if((device == NULL) || (buffer == NULL) || (device->user == NULL) )
		return 0;

	usbDevice = (LPUSB_DEVICE)device->user;

	ptr = buffer;

	MUTEX_LOCK(&usbDevice->sendBufferMutex);
	while(length > 0)
	{
		writeSize = usbDevice->endOfSendBuffer - (unsigned int)usbDevice->sendBufferWritePtr;

		writeSize = (length > writeSize) ? writeSize : length;

		memcpy(usbDevice->sendBufferWritePtr, ptr, writeSize);
		
		usbDevice->sendBufferWritePtr += writeSize;
		ptr += writeSize;
		length -= writeSize;

		if((unsigned int)usbDevice->sendBufferWritePtr == usbDevice->endOfSendBuffer)
			USBDevice_internalFlush(device, 0);
	}
	MUTEX_UNLOCK(&usbDevice->sendBufferMutex);

	return (ptr - buffer);
}
开发者ID:JaegarSarauer,项目名称:DCOMM-Assign2,代码行数:37,代码来源:USBDevice.c

示例15: tcs_wrap_ReadCurrentTicks

TSS_RESULT
tcs_wrap_ReadCurrentTicks(struct tcsd_thread_data *data)
{
    TCS_CONTEXT_HANDLE hContext;
    UINT32 pulCurrentTime;
    BYTE *prgbCurrentTime;
    TSS_RESULT result;

    if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
        return TCSERR(TSS_E_INTERNAL_ERROR);

    LogDebugFn("thread %ld context %x", THREAD_ID, hContext);

    MUTEX_LOCK(tcsp_lock);

    result = TCSP_ReadCurrentTicks_Internal(hContext, &pulCurrentTime, &prgbCurrentTime);

    MUTEX_UNLOCK(tcsp_lock);

    if (result == TSS_SUCCESS) {
        initData(&data->comm, 2);
        if (setData(TCSD_PACKET_TYPE_UINT32, 0, &pulCurrentTime, 0, &data->comm)) {
            free(prgbCurrentTime);
            return TCSERR(TSS_E_INTERNAL_ERROR);
        }
        if (setData(TCSD_PACKET_TYPE_PBYTE, 1, prgbCurrentTime, pulCurrentTime,
                    &data->comm)) {
            free(prgbCurrentTime);
            return TCSERR(TSS_E_INTERNAL_ERROR);
        }
        free(prgbCurrentTime);
    } else
        initData(&data->comm, 0);

    data->comm.hdr.u.result = result;
    return TSS_SUCCESS;
}
开发者ID:emilcondrea,项目名称:trousers,代码行数:37,代码来源:rpc_tick.c


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