コード例 #1
0
ファイル: v_participant.c プロジェクト: xrl/opensplice
void
v_participantInit(
    v_participant p,
    const c_char *name,
    v_participantQos qos,
    v_statistics s,
    c_bool enable)
{
    v_kernel kernel;
    c_base base;
    v_message builtinMsg;
    c_type writerProxyType;

    assert(C_TYPECHECK(p,v_participant));
    assert(C_TYPECHECK(qos, v_participantQos));

    kernel = v_objectKernel(p);
    base = c_getBase(p);
    v_observerInit(v_observer(p),name,s,enable);

    p->entities = c_setNew(c_resolve(base,"kernelModule::v_entity"));
    p->qos = c_keep(qos);
    /* Currently default LIVELINESS policy is used: kind=AUTOMATIC,
     * duration=INFINITE This setting implies no lease registration.
    */
    p->lease = NULL;
    p->leaseManager = v_leaseManagerNew(kernel);
    p->resendQuit = FALSE;
    c_mutexInit(&p->resendMutex, SHARED_MUTEX);
    c_condInit(&p->resendCond, &p->resendMutex, SHARED_COND);
    writerProxyType = v_kernelType(kernel,K_PROXY);
    p->resendWriters = c_tableNew(writerProxyType, "source.index,source.serial");

    p->builtinSubscriber = NULL;
    if (!v_observableAddObserver(v_observable(kernel),v_observer(p), NULL)) {
        if (name != NULL) {
            OS_REPORT_1(OS_WARNING,"Kernel Participant",0,
                        "%s: Cannot observe Kernel events",name);
        } else {
            OS_REPORT(OS_WARNING,"Kernel Participant",0,
                      "Cannot observe Kernel events");
        }
    }

    c_mutexInit(&p->newGroupListMutex,SHARED_MUTEX);
    p->newGroupList = c_listNew(c_resolve(base, "kernelModule::v_group"));

    v_observerSetEventMask(v_observer(p), V_EVENT_NEW_GROUP);

    c_lockInit(&p->lock,SHARED_LOCK);
    c_mutexInit(&p->builtinLock,SHARED_MUTEX);

    /* Here the Builtin Topic of the participant is published.
     * This call mabe a noop in case builtin is disabled on kernel level.
     */
    builtinMsg = v_builtinCreateParticipantInfo(kernel->builtin,p);
    v_writeBuiltinTopic(kernel, V_PARTICIPANTINFO_ID, builtinMsg);
    c_free(builtinMsg);
}
コード例 #2
0
ファイル: v_collection.c プロジェクト: xrl/opensplice_dds
/**************************************************************
 * Protected functions
 **************************************************************/
void
v_collectionInit(
    v_collection c,
    const c_char *name,
    v_statistics s,
    c_bool enable)
{
    c_base base;

    assert(C_TYPECHECK(c,v_collection));

    v_observerInit(v_observer(c), name, s, enable);
    base =  c_getBase(c_object(c));
    c->queries = c_setNew(c_resolve(base,"kernelModule::v_query"));
}
コード例 #3
0
ファイル: v_waitset.c プロジェクト: xrl/opensplice_dds
v_waitset
v_waitsetNew(
    v_participant p)
{
    v_waitset _this;
    v_kernel kernel;
    c_type proxyType;

    assert(C_TYPECHECK(p,v_participant));

    kernel = v_objectKernel(p);
    _this = v_waitset(v_objectNew(kernel,K_WAITSET));
    if (_this != NULL) {
        v_observerInit(v_observer(_this),"Waitset", NULL, TRUE);
        _this->participant = p;
        _this->eventCache = NULL;
        proxyType = v_kernelType(kernel,K_PROXY);
        _this->observables = c_setNew(proxyType);
        v_observerSetEventData(v_observer(_this), NULL);
        v_participantAdd(p, v_entity(_this));
    }

    return _this;
}
コード例 #4
0
ファイル: v_subscriber.c プロジェクト: S73417H/opensplice
v_subscriber
v_subscriberNew(
    v_participant p,
    const c_char *name,
    v_subscriberQos qos,
    c_bool enable)
{
    v_kernel kernel;
    v_subscriber s;
    v_subscriberQos q;
    v_entity found;
    v_accessMode access;

    kernel = v_objectKernel(p);
    /* ES, dds1576: If a partition policy was provided then we need to verify
     * if the partition policy does not contain any partition expressions for
     * which read access is not allowed.
     * If read access is not allowed for one of the partitions listed in the
     * partition policy of the qos, then the subscriber will not be created at
     * all.
     */
    if(qos && qos->partition)
    {
        access = v_kernelPartitionAccessMode(kernel, qos->partition);
    } else
    {
        access = V_ACCESS_MODE_READ_WRITE;/* default */
    }
    if(access == V_ACCESS_MODE_READ_WRITE || access == V_ACCESS_MODE_READ)
    {
        q = v_subscriberQosNew(kernel,qos);
        if (q != NULL) {
            s = v_subscriber(v_objectNew(kernel,K_SUBSCRIBER));
            v_observerInit(v_observer(s),name, NULL, enable);
            s->qos = q;
            c_mutexInit(&s->sharesMutex, SHARED_MUTEX);
            if (q->share.enable) {
                v_lockShares(kernel);
                found = v_addShareUnsafe(kernel,v_entity(s));
                if (found != v_entity(s)) {
                    /* Make sure to set the partition list to NULL, because
                     * v_publicFree will cause a crash in the v_subscriberDeinit
                     * otherwise.
                     */
                    s->partitions = NULL;
                    /*v_publicFree to free reference held by the handle server.*/
                    v_publicFree(v_public(s));
                    /*Now free the local reference as well.*/
                    c_free(s);
                    pa_increment(&(v_subscriber(found)->shareCount));
                    v_unlockShares(kernel);
                    return c_keep(found);
                }
                s->shares = c_tableNew(v_kernelType(kernel,K_READER),
                                       "qos.share.name");
            } else {
                s->shares = NULL;
            }
            s->shareCount  = 1;
            s->partitions  = v_partitionAdminNew(kernel);
            s->readers     = c_setNew(v_kernelType(kernel,K_READER));

            if (q->share.enable) {
                s->participant = kernel->builtin->participant;
            } else {
                s->participant = p;
            }

            c_lockInit(&s->lock,SHARED_LOCK);
            v_participantAdd(v_participant(s->participant),v_entity(s));

            if (q->share.enable) {
                v_unlockShares(kernel);
            }
            if (enable) {
                v_subscriberEnable(s);
            }
        } else {
            OS_REPORT(OS_ERROR,
                      "v_subscriberNew", 0,
                      "Subscriber not created: inconsistent qos");
            s = NULL;
        }
    } else
    {
        OS_REPORT(OS_ERROR,
              "v_subscriberNew", 0,
              "Subscriber not created: Access rights for one of the partitions listed in the partition list was not sufficient (i.e. read or readwrite).");
        s = NULL;
    }
    return s;
}