本文整理汇总了C++中MUTEX_UNLOCK函数的典型用法代码示例。如果您正苦于以下问题:C++ MUTEX_UNLOCK函数的具体用法?C++ MUTEX_UNLOCK怎么用?C++ MUTEX_UNLOCK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MUTEX_UNLOCK函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: tcs_wrap_GetTestResult
TSS_RESULT
tcs_wrap_GetTestResult(struct tcsd_thread_data *data)
{
TCS_CONTEXT_HANDLE hContext;
TSS_RESULT result;
UINT32 resultDataSize;
BYTE *resultData = NULL;
if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
return TCSERR(TSS_E_INTERNAL_ERROR);
LogDebugFn("thread %zd context %x", THREAD_ID, hContext);
MUTEX_LOCK(tcsp_lock);
result = TCSP_GetTestResult_Internal(hContext, &resultDataSize, &resultData);
MUTEX_UNLOCK(tcsp_lock);
if (result == TSS_SUCCESS) {
initData(&data->comm, 2);
if (setData(TCSD_PACKET_TYPE_UINT32, 0, &resultDataSize, 0, &data->comm)) {
free(resultData);
return TCSERR(TSS_E_INTERNAL_ERROR);
}
if (setData(TCSD_PACKET_TYPE_PBYTE, 1, resultData, resultDataSize, &data->comm)) {
free(resultData);
return TCSERR(TSS_E_INTERNAL_ERROR);
}
free(resultData);
} else
initData(&data->comm, 0);
data->comm.hdr.u.result = result;
return TSS_SUCCESS;
}
开发者ID:wy461132,项目名称:repository,代码行数:37,代码来源:rpc_selftest.c
示例17: bladerf_set_bandwidth
int bladerf_set_bandwidth(struct bladerf *dev, bladerf_module module,
unsigned int bandwidth,
unsigned int *actual)
{
int status;
lms_bw bw;
MUTEX_LOCK(&dev->ctrl_lock);
if (bandwidth < BLADERF_BANDWIDTH_MIN) {
bandwidth = BLADERF_BANDWIDTH_MIN;
log_info("Clamping bandwidth to %dHz\n", bandwidth);
} else if (bandwidth > BLADERF_BANDWIDTH_MAX) {
bandwidth = BLADERF_BANDWIDTH_MAX;
log_info("Clamping bandwidth to %dHz\n", bandwidth);
}
bw = lms_uint2bw(bandwidth);
status = lms_lpf_enable(dev, module, true);
if (status != 0) {
goto out;
}
status = lms_set_bandwidth(dev, module, bw);
if (actual != NULL) {
if (status == 0) {
*actual = lms_bw2uint(bw);
} else {
*actual = 0;
}
}
out:
MUTEX_UNLOCK(&dev->ctrl_lock);
return status;
}
开发者ID:modustollens,项目名称:bladeRF,代码行数:37,代码来源:bladerf.c
示例18: check_samplerate
/* Require a 10% margin on the sample rate to ensure we can keep up, and
* warn if this margin is violated.
*
* We effectively ensuring:
*
* Min sample rate > (xfers / timeout period) * samples / buffer
* ^
* 1 xfer = buffer --'
*/
static void check_samplerate(struct cli_state *s, struct rxtx_data *rxtx)
{
int status;
uint64_t samplerate_min; /* Min required sample rate */
unsigned int samplerate_dev; /* Device's current sample rate */
unsigned int n_xfers, samp_per_buf, timeout_ms;
MUTEX_LOCK(&rxtx->data_mgmt.lock);
n_xfers = (unsigned int)rxtx->data_mgmt.num_transfers;
samp_per_buf = (unsigned int)rxtx->data_mgmt.samples_per_buffer;
timeout_ms = rxtx->data_mgmt.timeout_ms;
MUTEX_UNLOCK(&rxtx->data_mgmt.lock);
samplerate_min = (uint64_t)n_xfers * samp_per_buf * 1000 / timeout_ms;
samplerate_min += (samplerate_min + 9) / 10;
status = bladerf_get_sample_rate(s->dev, rxtx->module, &samplerate_dev);
if (status < 0) {
cli_err(s, "Error", "Failed read device's current sample rate. "
"Unable to perform sanity check.\n");
} else if (samplerate_dev < samplerate_min) {
if (samplerate_min <= 40000000) {
printf("\n");
printf(" Warning: The current sample rate may be too low. For %u transfers,\n"
" %u samples per buffer, and a %u ms timeout, a sample rate\n"
" over %"PRIu64" Hz may be required. Alternatively, the 'timeout'\n"
" parameter could be increased, but may yield underruns.\n\n",
n_xfers, samp_per_buf, timeout_ms, samplerate_min);
} else {
printf("\n");
printf(" Warning: The current configuraion with %u transfers,\n"
" %u samples per buffer, and a %u ms timeout requires a\n"
" sample rate above 40MHz. Timeouts may occur with these settings.\n\n",
n_xfers, samp_per_buf, timeout_ms);
}
}
}
开发者ID:HKingz,项目名称:bladeRF,代码行数:46,代码来源:rxtx.c
示例19: tcs_wrap_CMK_SetRestrictions
TSS_RESULT
tcs_wrap_CMK_SetRestrictions(struct tcsd_thread_data *data)
{
TCS_CONTEXT_HANDLE hContext;
TSS_CMK_DELEGATE restriction;
TPM_AUTH ownerAuth;
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);
if (getData(TCSD_PACKET_TYPE_UINT32, 1, &restriction, 0, &data->comm))
return TCSERR(TSS_E_INTERNAL_ERROR);
if (getData(TCSD_PACKET_TYPE_AUTH, 2, &ownerAuth, 0, &data->comm))
return TCSERR(TSS_E_INTERNAL_ERROR);
MUTEX_LOCK(tcsp_lock);
result = TCSP_CMK_SetRestrictions_Internal(hContext, restriction, &ownerAuth);
MUTEX_UNLOCK(tcsp_lock);
if (result == TSS_SUCCESS) {
initData(&data->comm, 1);
if (setData(TCSD_PACKET_TYPE_AUTH, 0, &ownerAuth, 0, &data->comm))
return TCSERR(TSS_E_INTERNAL_ERROR);
} else
initData(&data->comm, 0);
data->comm.hdr.u.result = result;
return TSS_SUCCESS;
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:36,代码来源:rpc_cmk.c
示例20: _stage_2_
void
_stage_2_ ()
{
MUTEX_DECL (_stage_2_series_block_stmt_28_c_mutex_);
MUTEX_LOCK (_stage_2_series_block_stmt_28_c_mutex_);
_stage_2_inner_inarg_prep_macro__;
_stage_2_branch_block_stmt_29_c_export_decl_macro_;
{
// merge file ShiftRegister.aa, line 41
_stage_2_merge_stmt_30_c_preamble_macro_;
_stage_2_merge_stmt_30_c_postamble_macro_;
// tval := ($bitcast ($uint<16>) midpipe )// bits of buffering = 16
_stage_2_assign_stmt_34_c_macro_;
// outpipe := tval// bits of buffering = 16
_stage_2_assign_stmt_37_c_macro_;
// $report (stage_2 sent output tval )
_stage_2_stmt_39_c_macro_;
/* $place[loopback]
*/ goto loopback_29;
_stage_2_branch_block_stmt_29_c_export_apply_macro_;
}
_stage_2_inner_outarg_prep_macro__;
MUTEX_UNLOCK (_stage_2_series_block_stmt_28_c_mutex_);
}
开发者ID:madhavPdesai,项目名称:ahir,代码行数:24,代码来源:aa_c_model.c
注:本文中的MUTEX_UNLOCK函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论