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


C++ os_mutexUnlock函数代码示例

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


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

示例1: os__signalHandlerCallbackDeinit

static void
os__signalHandlerCallbackDeinit(
        os_signalHandlerCallbackInfo *_this)
{
    os_signalHandlerExceptionCallbackInfo *ecb;
    os_signalHandlerExitRequestCallbackInfo *ercb;

    assert(_this);

    os_mutexLock(&_this->exceptionMtx);
    while((ecb = _this->exceptionCallbackInfo) != NULL){
        _this->exceptionCallbackInfo = _this->exceptionCallbackInfo->next;
        os_signalHandlerExceptionRequestCallbackInfoDeinit(ecb);
        os_free(ecb);
    }
    os_mutexUnlock(&_this->exceptionMtx);
    os_mutexDestroy(&_this->exceptionMtx);

    os_mutexLock(&_this->exitRequestMtx);
    while((ercb = _this->exitRequestCallbackInfo) != NULL){
        _this->exitRequestCallbackInfo = _this->exitRequestCallbackInfo->next;
        os_signalHandlerExitRequestCallbackInfoDeinit(ercb);
        os_free(ercb);
    }
    os_mutexUnlock(&_this->exitRequestMtx);
    os_mutexDestroy(&_this->exitRequestMtx);
}
开发者ID:osrf,项目名称:opensplice,代码行数:27,代码来源:os_signalHandlerCallback.c

示例2: u_readerDeinit

u_result
u_readerDeinit(
    u_reader _this)
{
    u_result result;
    u_query query;

    if (_this != NULL) {
        result = u_dispatcherDeinit(u_dispatcher(_this));
        if (result == U_RESULT_OK) {
            os_mutexLock(&_this->mutex);
            if (_this->queries) {
                query = c_iterObject(_this->queries,0);
                while (query) {
                    os_mutexUnlock(&_this->mutex);
                    result = u_queryFree(query);
                    os_mutexLock(&_this->mutex);
                    query = c_iterObject(_this->queries,0);
                }
                c_iterFree(_this->queries);
                _this->queries = NULL;
            }
            os_mutexUnlock(&_this->mutex);
            os_mutexDestroy(&_this->mutex);
        }
    } else {
        result = U_RESULT_ILL_PARAM;
    }

    return result;
}
开发者ID:S73417H,项目名称:opensplice,代码行数:31,代码来源:u_reader.c

示例3: cms_clientFree

void
cms_clientFree(
    cms_client client)
{
    struct soap* soap;
    cms_soapThread soapThread;

    cms_thread(client)->terminate = TRUE;

    os_mutexLock(&client->conditionMutex);
    os_condSignal(&client->condition);
    os_mutexUnlock(&client->conditionMutex);

    cms_threadDeinit(cms_thread(client));

    if(client->soapEnvs){
        os_mutexLock(&client->soapMutex);
        soap = (struct soap*)(c_iterTakeFirst(client->soapEnvs));

        while(soap){
            soap->error = soap_receiver_fault(soap, "Service is terminating.", NULL);
            soap_send_fault(soap);
            soap_destroy(soap);
            soap_end(soap);
            soap_done(soap);
            os_free(soap);
            soap = (struct soap*)(c_iterTakeFirst(client->soapEnvs));
        }
        c_iterFree(client->soapEnvs);
        client->soapEnvs = NULL;
        os_mutexUnlock(&client->soapMutex);
    }

    if(client->threads){
        soapThread = cms_soapThread(c_iterTakeFirst(client->threads));

        while(soapThread){
            cms_soapThreadFree(soapThread);
            (void)u_observableAction(u_observable(client->service->uservice), cms_clientStatisticsThreadRemove, client->service);
            soapThread = cms_soapThread(c_iterTakeFirst(client->threads));
        }
        c_iterFree(client->threads);
        client->threads = NULL;
    }
    os_mutexDestroy(&client->soapMutex);
    os_mutexDestroy(&client->threadMutex);
    os_mutexDestroy(&client->conditionMutex);
    os_condDestroy(&client->condition);
    client->initCount = 0;

    if(client->service->configuration->verbosity >= 5){
        OS_REPORT(OS_INFO, CMS_CONTEXT, 0,
                        "Client thread stopped for IP: %d.%d.%d.%d",
                        (int)(client->ip>>24)&0xFF,
                        (int)(client->ip>>16)&0xFF,
                        (int)(client->ip>>8)&0xFF,
                        (int)(client->ip&0xFF));
    }
开发者ID:osrf,项目名称:opensplice,代码行数:58,代码来源:cms_client.c

示例4: dispatch

static void *
dispatch(
    void *o)
{
    u_dispatcher _this;
    v_observer claim;
    struct listenerExecArg arg;
    u_result result;

    _this = u_dispatcher(o);
    if (_this != NULL) {
        if (_this->startAction) {
            _this->startAction(_this, _this->actionData);
        }
        os_mutexLock(&_this->mutex);
        result = u_entityReadClaim(u_entity(_this), (v_entity*)(&claim));
        if(result == U_RESULT_OK) {
            assert(claim);
            while ((!(_this->event & V_EVENT_OBJECT_DESTROYED)) &&
                   (_this->listeners != NULL) &&
                   (c_iterLength(_this->listeners) > 0)) {

                os_mutexUnlock(&_this->mutex);
                _this->event = v_observerWait(claim);
                os_mutexLock(&_this->mutex);
                if (!(_this->event & V_EVENT_OBJECT_DESTROYED)) {
                    /* do not call listeners when  object is destroyed! */
                    arg.mask = 0;
                    arg.o = _this;
                    c_iterWalk(_this->listeners,
                               (c_iterWalkAction)listenerExecute,
                               &arg);
                }
            }
            _this->threadId = OS_THREAD_ID_NONE;
            result = u_entityRelease(u_entity(_this));
            if (result != U_RESULT_OK) {
                OS_REPORT(OS_ERROR, "u_dispatcher::dispatch", 0,
                          "Release observer failed.");
            }
        } else {
            OS_REPORT(OS_WARNING, "u_dispatcher::dispatch", 0,
                      "Failed to claim Dispatcher.");
        }
        os_mutexUnlock(&_this->mutex);
        if (_this->stopAction) {
            _this->stopAction(_this, _this->actionData);
        }
    } else {
        OS_REPORT(OS_ERROR, "u_dispatcher::dispatch", 0,
                  "No dispatcher specified.");
    }
    return NULL;
}
开发者ID:S73417H,项目名称:opensplice,代码行数:54,代码来源:u_dispatcher.c

示例5: gapi_handleReadRelease

static void
gapi_handleReadRelease (
    gapi_handle handle)
{
    os_mutexLock(&handle->read);
    handle->count--;
    if (handle->count == 0) {
        os_mutexUnlock(&handle->mutex);
    }
    os_mutexUnlock(&handle->read);
}
开发者ID:diorahman,项目名称:opensplice,代码行数:11,代码来源:gapi_object.c

示例6: u_dispatcherDeinit

u_result
u_dispatcherDeinit(
    u_dispatcher _this)
{
    v_observer ko;
    u_listener listener;
    os_threadId tid;
    u_result result = U_RESULT_OK;

    if (_this != NULL) {
        os_mutexLock(&_this->mutex);
        listener = u_listener(c_iterTakeFirst(_this->listeners));
        while (listener != NULL) {
            u_listenerFree(listener);
            listener = u_listener(c_iterTakeFirst(_this->listeners));
        }
        c_iterFree(_this->listeners);
        _this->listeners = NULL; /* Flags the dispatch thread to stop */
        if (os_threadIdToInteger(_this->threadId) != 0U) {
            tid = _this->threadId;
            result = u_entityReadClaim(u_entity(_this), (v_entity*)(&ko));
            if(result != U_RESULT_OK) {
                /* This is a valid situation when a participant has been
                 * freed prior to the freeing of a dispatcher within the
                 * participant.
                 */
                os_mutexUnlock(&_this->mutex);
                os_threadWaitExit(tid, NULL);
                os_mutexDestroy(&_this->mutex);
                /*return U_RESULT_INTERNAL_ERROR;*/
            } else {
                /* Wakeup the dispatch thread */
                v_observerLock(ko);
                v_observerNotify(ko, NULL, NULL);
                v_observerUnlock(ko);
                u_entityRelease(u_entity(_this));
                os_mutexUnlock(&_this->mutex);
                os_threadWaitExit(tid, NULL);
                os_mutexDestroy(&_this->mutex);
            }
        } else {
            os_mutexUnlock(&_this->mutex);
            os_mutexDestroy(&_this->mutex);
        }
        result = u_entityDeinit(u_entity(_this));
    } else {
        OS_REPORT(OS_ERROR,"u_dispatcherDeinit",0,
                  "Illegal parameter.");
        result = U_RESULT_ILL_PARAM;
    }
    return result;
}
开发者ID:S73417H,项目名称:opensplice,代码行数:52,代码来源:u_dispatcher.c

示例7: cms_serviceCollectGarbage

static void*
cms_serviceCollectGarbage(
    void* arg)
{
    cms_service cms;
    os_time update;
    cms_thread client;
    c_bool garbagePresent;

    cms = cms_service(arg);
    update.tv_sec = 2;
    update.tv_nsec = 0;

    garbagePresent = FALSE;

    /*
     * Keep going until service terminates AND all garbage has been collected.
     */
    while((cms->terminate == FALSE) || (c_iterLength(cms->clientGarbage) != 0)) {
        os_mutexLock(&cms->clientMutex);
        client = cms_thread(c_iterTakeFirst(cms->clientGarbage));
        os_mutexUnlock(&cms->clientMutex);

        while(client != NULL) {
            /*
             * Call threadFree and NOT clientFree on purpose.
             */
            cms_threadFree(client);
            os_mutexLock(&cms->clientMutex);
            client = cms_thread(c_iterTakeFirst(cms->clientGarbage));
            os_mutexUnlock(&cms->clientMutex);
            garbagePresent = TRUE;
        }

        if((c_iterLength(cms->clients) == 0) && (garbagePresent == TRUE)) {
            if(cms->configuration->verbosity >= 3) {
                OS_REPORT(OS_INFO, CMS_CONTEXT, 0,
                          "No clients connected. Performing some garbage collecting...");
            }
            cmx_deregisterAllEntities();
            garbagePresent = FALSE;
        }


        if(cms->terminate == FALSE) {
            os_nanoSleep(update);
        }
    }
    c_iterFree(cms->clientGarbage);

    return NULL;
}
开发者ID:shizhexu,项目名称:opensplice,代码行数:52,代码来源:cms_service.c

示例8: os__signalHandlerExitRequestCallbackInvoke

static os_uint32
os__signalHandlerExitRequestCallbackInvoke(
        os_signalHandlerCallbackInfo *_this,
        os_callbackArg arg)
{
    os_result osr;
    os_signalHandlerExitRequestCallbackInfo *cbExit;
    os_uint32 nrCallbacks = 0;

    assert(_this);
    os_mutexLock(&_this->exitRequestMtx);
    cbExit = _this->exitRequestCallbackInfo;
    /* Don't process handlers that have just been added, since we did not obtain
     * the proper context. */
    while(cbExit){
        os_signalHandlerThreadContextBuffer *contextBuffer = &(cbExit->contextBuffer[_this->exitRequestConsumptionIndex]);
        if (!cbExit->deregistered && cbExit->callbackExitRequest &&
                (contextBuffer->contextAssigned || !cbExit->callbackGetThreadContext)) {
            osr = cbExit->callbackExitRequest(arg, contextBuffer->threadContext, cbExit->arg);
            nrCallbacks++;
            if(osr != os_resultSuccess) {
                OS_REPORT(OS_ERROR, "os_signalHandlerThread", 0,
                          "Exit request-callback returned: %s",
                          os_resultImage(osr));
            }
        }
        contextBuffer->contextAssigned = FALSE;
        cbExit = cbExit->next;
    }
    _this->exitRequestConsumptionIndex++;
    os_mutexUnlock(&_this->exitRequestMtx);

    return nrCallbacks;
}
开发者ID:osrf,项目名称:opensplice,代码行数:34,代码来源:os_signalHandlerCallback.c

示例9: cmx_readerSnapshotNew

c_char*
cmx_readerSnapshotNew(
    const c_char* reader)
{
    cmx_entity ce;
    c_char* result;
    struct cmx_readerSnapshotArg arg;
    os_mutex m;

    arg.success = FALSE;
    result = NULL;

    ce = cmx_entityClaim(reader);
    if(ce != NULL){
        if (u_observableAction(u_observable(ce->uentity),
                               cmx_readerSnapshotNewAction,
                               &arg) == U_RESULT_OK)
        {
            if(arg.success == TRUE){
                m = cmx_getReaderSnapshotMutex();
                os_mutexLock(&m);
                readerSnapshots = c_iterInsert(readerSnapshots, arg.snapshot);
                os_mutexUnlock(&m);

                result = (c_char*)(os_malloc(60));
                os_sprintf(result,
                           "<readerSnapshot><id>"PA_ADDRFMT"</id></readerSnapshot>",
                           (c_address)(arg.snapshot));
            }
        }
        cmx_entityRelease(ce);
    }
    return result;
}
开发者ID:osrf,项目名称:opensplice,代码行数:34,代码来源:cmx_readerSnapshot.c

示例10: s_shmMonitorFree

os_boolean
s_shmMonitorFree(
    s_shmMonitor _this)
{
    os_boolean result = OS_TRUE;
    s_configuration config;
    os_result osr;

    if (_this != NULL) {
        config = splicedGetConfiguration(_this->spliceDaemon);
        os_mutexLock(&_this->mutex);
        _this->terminate = OS_TRUE;
        os_mutexUnlock(&_this->mutex);
        if (_this->thr != NULL) {
            osr = ut_threadTimedWaitExit(_this->thr, config->serviceTerminatePeriod, NULL);
            if (osr != os_resultSuccess) {
                OS_REPORT(OS_ERROR, OS_FUNCTION, osr,
                    "Failed to join thread \"%s\":0x%" PA_PRIxADDR " (%s)",
                    ut_threadGetName(_this->thr),
                    (os_address)os_threadIdToInteger(ut_threadGetId(_this->thr)),
                    os_resultImage(osr));
                result = OS_FALSE;
            }
        }
        if (result) {
            os_mutexDestroy(&_this->mutex);
            os_condDestroy(&_this->cleanCondition);
            os_free(_this);
        }
    }
    return result;
}
开发者ID:osrf,项目名称:opensplice,代码行数:32,代码来源:s_shmMonitor.c

示例11: _ObjectRegistryFree

void
_ObjectRegistryFree (
    _ObjectRegistry registry)
{
    gapi_handle handle;
    int ptr;

    assert(registry);

    os_mutexLock(&registry->mutex);

    ptr = 0;
    while ( registry->trash[ptr] != NULL ) {
        gapi__free(registry->trash[ptr]);
        registry->trash[ptr] = NULL;
        ptr = (ptr + 1)%TRASH_LENGTH;
    }

    handle = c_iterTakeFirst(registry->active);
    while ( handle != NULL ) {
        handle->registry = NULL;
        gapi__free(handle);
        handle = c_iterTakeFirst(registry->active);
    }
    c_iterFree(registry->active);

    os_mutexUnlock(&registry->mutex);
    os_mutexDestroy(&registry->mutex);

    os_free(registry);
}
开发者ID:diorahman,项目名称:opensplice,代码行数:31,代码来源:gapi_object.c

示例12: cms_soapThreadRun

static void*
cms_soapThreadRun(
    void *thr)
{
    cms_soapThread thread;
    struct soap* soap;
    c_char* result;

    thread = cms_soapThread(thr);
    os_mutexLock(&thread->soapMutex);

    while(cms_thread(thread)->terminate == FALSE){

        if(thread->soap != NULL){
            soap = thread->soap;
            thread->soap = NULL;

            cms_thread(thread)->results = NULL;
            soap->user = thr;
            soap_serve(soap);
            soap_destroy(soap);
            soap_end(soap);
            soap_done(soap);
            free(soap);
            u_entityAction( u_entity(thread->client->service->uservice),
                            cms_soapThreadStatisticsRequestHandledAdd,
                            thread->client->service);

            if(cms_thread(thread)->results != NULL){
                result = (c_char*)(c_iterTakeFirst(cms_thread(thread)->results));

                while(result){
                    os_free(result);
                    result = (c_char*)(c_iterTakeFirst(cms_thread(thread)->results));
                }
                c_iterFree(cms_thread(thread)->results);
                cms_thread(thread)->results = NULL;
            }
        }

        if(cms_thread(thread)->terminate == FALSE){
            cms_thread(thread)->ready = TRUE;

            if(thread->client->service->configuration->verbosity >= 7){
                OS_REPORT_1(OS_INFO, CMS_CONTEXT, 0,  "soapThread '%s' ready.", cms_thread(thread)->name);
            }
            os_condWait(&thread->condition, &thread->soapMutex);

            if(thread->client->service->configuration->verbosity >= 7){
                OS_REPORT_1(OS_INFO, CMS_CONTEXT, 0,  "soapThread '%s' condition triggered.", cms_thread(thread)->name);
            }
        }
    }
    os_mutexUnlock(&thread->soapMutex);

    if(thread->client->service->configuration->verbosity >= 6){
        OS_REPORT_1(OS_INFO, CMS_CONTEXT, 0,  "soapThread '%s' ends.", cms_thread(thread)->name);
    }
    return NULL;
}
开发者ID:S73417H,项目名称:opensplice,代码行数:60,代码来源:cms_soapThread.c

示例13: u__userLock

/* This method will lock the user-layer and return the reference to the user-layer object if successful.
 * If this method returns NULL then the user-layer is either not initialized or
 * the process is detaching (process termination).
 */
static u_user
u__userLock(void)
{
    u_user u;
    os_result r = os_resultFail;

    u = u_user(user);
    if (u) {
        r = os_mutexLock(&u->mutex);
        if (r != os_resultSuccess) {
            /* The mutex is not valid so apparently the user-layer is either
             * destroyed or in process of destruction. */
            u = NULL;
        } else if ((os_threadIdToInteger(u->detachThreadId) != 0) &&
                   (os_threadIdToInteger(u->detachThreadId) !=
                    os_threadIdToInteger(os_threadIdSelf())))
        {
            /* Another thread is busy destroying the user-layer or the user-
             * layer is already destroyed. No access is allowed (anymore).
             * The user-layer object will be unlocked and will return null.
             */
            os_mutexUnlock(&u->mutex);
            u = NULL;
        }
    } else {
        /* The user-layer is not created or destroyed i.e. non existent, therefore return null. */
        OS_REPORT(OS_ERROR, "User Layer", 0, "User layer not initialized");
    }
    return u;
}
开发者ID:cynron,项目名称:opensplice,代码行数:34,代码来源:u_user.c

示例14: os_signalHandlerRegisterExceptionCallback

os_signalHandlerExceptionHandle
os_signalHandlerRegisterExceptionCallback(
    os_signalHandlerExceptionCallback cbException,
    os_signalHandlerAllocThreadContextCallback cbAllocThreadContext,
    os_signalHandlerGetThreadContextCallback cbGetThreadContext,
    os_signalHandlerFreeThreadContextCallback cbFreeThreadContext,
    void * arg)
{
    os_signalHandlerExceptionHandle ret;
    os_signalHandlerExceptionCallbackInfo *cb;
    os_signalHandlerCallbackInfo *_this = os__signalHandlerGetCallbackInfo();

    ret.handle = cb = os_malloc(sizeof *cb);

    cb->callbackException = cbException;
    cb->callbackGetThreadContext = cbGetThreadContext;
    cb->callbackFreeThreadContext = cbFreeThreadContext;
    cb->threadContext = cbAllocThreadContext ? cbAllocThreadContext() : NULL;
    cb->arg = arg;

    os_mutexLock(&_this->exceptionMtx);
    cb->next = _this->exceptionCallbackInfo;
    _this->exceptionCallbackInfo = cb;
    os_mutexUnlock(&_this->exceptionMtx);

    return ret;
}
开发者ID:osrf,项目名称:opensplice,代码行数:27,代码来源:os_signalHandlerCallback.c

示例15: os_signalHandlerRegisterExitRequestCallback

os_signalHandlerExitRequestHandle
os_signalHandlerRegisterExitRequestCallback(
    os_signalHandlerExitRequestCallback callback,
    os_signalHandlerAllocThreadContextCallback cbAllocThreadContext,
    os_signalHandlerGetThreadContextCallback cbGetThreadContext,
    os_signalHandlerFreeThreadContextCallback cbFreeThreadContext,
    void * arg)
{
    os_signalHandlerExitRequestHandle ret;
    os_signalHandlerExitRequestCallbackInfo *cb;
    os_signalHandlerCallbackInfo *_this = os__signalHandlerGetCallbackInfo();
    int i;

    ret.handle = cb = os_malloc(sizeof *cb);

    cb->callbackExitRequest = callback;
    cb->callbackGetThreadContext = cbGetThreadContext;
    cb->callbackFreeThreadContext = cbFreeThreadContext;
    for (i = 0; i < EXIT_REQUEST_BUFFER_SIZE; i++) {
        cb->contextBuffer[i].contextAssigned = FALSE;
        cb->contextBuffer[i].threadContext = cbAllocThreadContext ? cbAllocThreadContext() : NULL;
    }
    cb->arg = arg;
    cb->deregistered = OS_FALSE;

    os_mutexLock(&_this->exitRequestMtx);
    cb->next = _this->exitRequestCallbackInfo;
    _this->exitRequestCallbackInfo = cb;
    _this->nrExitRequestHandlers++;
    os_mutexUnlock(&_this->exitRequestMtx);

    return ret;
}
开发者ID:osrf,项目名称:opensplice,代码行数:33,代码来源:os_signalHandlerCallback.c


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