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


C++ os_mutexLock函数代码示例

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


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

示例1: 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

示例2: 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

示例3: c_mutexLock

c_syncResult
c_mutexLock (
    c_mutex *mtx)
{
    os_result result;

#ifdef NDEBUG
    result = os_mutexLock(mtx);
#else
    result = os_mutexLock(&mtx->mtx);
    if ( result == os_resultSuccess )
    {
       mtx->owner = os_threadIdSelf();
    }
#endif
#if 1
    /* TODO: Remove temporary workaround to prevent spinning
     * applications and come up with an actual fix.
     */
    wait_on_error(result);
#endif
    if(result != os_resultSuccess) {
        OS_REPORT_1(OS_ERROR, "c_mutexLock", 0, "os_mutexLock failed; os_result = %d.", result);
        assert(result == os_resultSuccess);
    }

    return result;
}
开发者ID:xrl,项目名称:opensplice,代码行数:28,代码来源:c_sync.c

示例4: 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

示例5: gapi_handleReadClaim

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

示例6: 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

示例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: u_readerContainsQuery

c_bool
u_readerContainsQuery(
    u_reader _this,
    u_query query)
{
    c_bool found = FALSE;
    os_result r;

    if (_this && query) {
        if(u_entityOwner(u_entity(_this))) {
            r = os_mutexLock(&_this->mutex);
            if (r == os_resultSuccess) {
                found = c_iterContains(_this->queries,query);
                os_mutexUnlock(&_this->mutex);
            } else {
                OS_REPORT(OS_WARNING,
                          "u_readerContainsQuery",0,
                          "Failed to lock Reader.");
            }
        }
    } else {
        OS_REPORT(OS_WARNING,
                  "u_readerRemoveQuery",0,
                  "Illegal parameter.");
    }
    return found;
}
开发者ID:S73417H,项目名称:opensplice,代码行数:27,代码来源:u_reader.c

示例9: u_readerLookupQueries

c_iter
u_readerLookupQueries(
    u_reader _this)
{
    c_iter queries = NULL;
    os_result r;

    if (_this) {
        if(u_entityOwner(u_entity(_this))) {
            r = os_mutexLock(&_this->mutex);
            if (r == os_resultSuccess) {
                c_iterWalk(_this->queries, collect_queries, &queries);
                os_mutexUnlock(&_this->mutex);
            } else {
                OS_REPORT(OS_WARNING,
                          "u_readerLookupQueries",0,
                          "Failed to lock Reader.");
            }
        }
    } else {
        OS_REPORT(OS_WARNING,
                  "u_readerLookupQueries",0,
                  "No Reader specified.");
    }
    return queries;
}
开发者ID:S73417H,项目名称:opensplice,代码行数:26,代码来源:u_reader.c

示例10: u_readerAddQuery

u_result
u_readerAddQuery(
    u_reader _this,
    u_query query)
{
    os_result r;
    u_result result = U_RESULT_PRECONDITION_NOT_MET;

    if (_this && query) {
        if(u_entityOwner(u_entity(_this))) {
            r = os_mutexLock(&_this->mutex);
            if (r == os_resultSuccess) {
                _this->queries = c_iterInsert(_this->queries, query);
                os_mutexUnlock(&_this->mutex);
                result = U_RESULT_OK;
            } else {
                OS_REPORT(OS_WARNING,
                          "u_readerAddQuery",0,
                          "Failed to lock Reader.");
                result = U_RESULT_ILL_PARAM;
            }
        } else {
            result = U_RESULT_OK;
        }
    } else {
        OS_REPORT(OS_WARNING,
                  "u_readerAddQuery",0,
                  "Illegal parameter.");
        result = U_RESULT_ILL_PARAM;
    }
    return result;
}
开发者ID:S73417H,项目名称:opensplice,代码行数:32,代码来源:u_reader.c

示例11: 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

示例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: cmx_readerSnapshotNew

c_char*
cmx_readerSnapshotNew(
    const c_char* reader)
{
    u_entity e;
    c_char* result;
    struct cmx_readerSnapshotArg arg;
    os_mutex m;
    
    arg.success = FALSE;
    result = NULL;
    e = cmx_entityUserEntity(reader);
    
    if(e != NULL){    
        u_entityAction(e, cmx_readerSnapshotNewAction, &arg);
        
        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));
        }
    }
    return result;
}
开发者ID:xrl,项目名称:opensplice_dds,代码行数:28,代码来源:cmx_readerSnapshot.c

示例14: 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

示例15: 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


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