Example #1
0
void
v_subscriberFree(
    v_subscriber s)
{
    v_kernel kernel;
    v_participant p;
    v_reader o;
    v_entity found;
    c_long sc;

    kernel = v_objectKernel(s);

    sc = (c_long)pa_decrement(&(s->shareCount));
    if (sc > 0) return;

    if(sc == 0){
        v_observableRemoveObserver(v_observable(kernel->groupSet),v_observer(s), NULL);
        if (s->qos->share.enable) {
            found = v_removeShare(kernel,v_entity(s));
            assert(found == v_entity(s));
            c_free(found);
        }
        while ((o = c_take(s->readers)) != NULL) {
            switch (v_objectKind(o)) {
            case K_DATAREADER:
                v_dataReaderFree(v_dataReader(o));
            break;
            case K_DELIVERYSERVICE:
                v_deliveryServiceFree(v_deliveryService(o));
            break;
            case K_GROUPQUEUE:
                v_groupQueueFree(v_groupQueue(o));
            break;
            case K_NETWORKREADER:
                v_networkReaderFree(v_networkReader(o));
            break;
            default:
                OS_REPORT_1(OS_ERROR,
                            "v_subscriber", 0,
                            "Unknown reader %d",
                            v_objectKind(o));
                assert(FALSE);
            break;
            }
            c_free(o);
        }
        p = v_participant(s->participant);
        if (p != NULL) {
            v_participantRemove(p,v_entity(s));
            s->participant = NULL;
        }
        v_publicFree(v_public(s));
    } else {
        OS_REPORT_1(OS_ERROR,  "v_subscriberFree", 0,
                "subscriber already freed (shareCount is now %d).", sc);
        assert(sc == 0);
    }
}
Example #2
0
void
v_waitsetFree(
   v_waitset _this)
{
    v_kernel kernel;
    v_participant p;

    assert(_this != NULL);
    assert(C_TYPECHECK(_this,v_waitset));

    kernel = v_objectKernel(_this);
    p = v_participant(_this->participant);
    if (p != NULL) {
        v_participantRemove(p, v_entity(_this));
        _this->participant = NULL;
    }
    v_observerFree(v_observer(_this));
}
Example #3
0
void
v_topicAdapterFree(
    v_topicAdapter adapter)
{
    v_participant p;

    assert(C_TYPECHECK(adapter,v_topicAdapter));

    p = v_topicAdapterParticipant(adapter);

    OSPL_REMOVE_OBSERVER(adapter->topic, adapter, V_EVENTMASK_ALL, NULL);
    OSPL_REMOVE_OBSERVER(adapter, p, V_EVENTMASK_ALL, NULL);

    if (p != NULL) {
        v_participantRemove(p,v_object(adapter));
        v_topic(adapter)->owner = NULL;
    }

    v_entityFree(v_entity(adapter));
}
Example #4
0
void
v_listenerFree(
   v_listener _this)
{
    v_participant p;
    v_listenerEvent event;
    os_duration delay;

    assert(_this != NULL);
    assert(C_TYPECHECK(_this,v_listener));
    p = v_participant(_this->participant);
    assert(p != NULL);

    c_mutexLock(&_this->mutex);

    /* wakeup blocking threads to evaluate new condition. */
    /* remove all events */
    while (_this->eventList != NULL) {
        event = _this->eventList;
        _this->eventList = event->next;
        v_listenerEventDeinit(event);
        c_free(event);
    }
    _this->eventList = NULL;
    c_free(_this->lastEvent);
    _this->lastEvent = NULL;
    _this->terminate = TRUE;
    c_condBroadcast(&_this->cv);
    c_mutexUnlock(&_this->mutex);

    delay = OS_DURATION_INIT(0, 1000);
    while (_this->waitCount > 0 && !p->processIsZombie) {
        ospl_os_sleep(delay);
    }

    v_participantRemove(p, v_object(_this));
    _this->participant = NULL;
    v_publicFree(v_public(_this));
}