예제 #1
0
파일: u_group.c 프로젝트: xrl/opensplice
u_result
u_groupFree(
    u_group _this)
{
    u_result result;
    c_bool destroy;

    result = u_entityLock(u_entity(_this));
    if (result == U_RESULT_OK) {
        destroy = u_entityDereference(u_entity(_this));
        /* if refCount becomes zero then this call
         * returns true and destruction can take place
         */
        if (destroy) {
            /* This user entity is a proxy, meaning that it is not fully
             * initialized, therefore only the entity part of the object
             * can be deinitialized.
             * It would be better to either introduce a separate proxy
             * entity for clarity or fully initialize entities and make
             * them robust against missing information.
             */
            result = u_entityDeinit(u_entity(_this));

            if (result == U_RESULT_OK) {
                u_entityDealloc(u_entity(_this));
            } else {
                OS_REPORT_2(OS_WARNING,
                            "u_groupFree",0,
                            "Operation u_groupDeinit failed: "
                            "Waitset = 0x%x, result = %s.",
                            _this, u_resultImage(result));
                u_entityUnlock(u_entity(_this));
            }
        } else {
            u_entityUnlock(u_entity(_this));
        }
    } else {
        OS_REPORT_2(OS_WARNING,
                    "u_groupFree",0,
                    "Operation u_entityLock failed: "
                    "Waitset = 0x%x, result = %s.",
                    _this, u_resultImage(result));
    }
    return result;
}
예제 #2
0
u_result
u_topicFree(
    u_topic _this)
{
    u_result result;
    c_bool destroy;

    result = u_entityLock(u_entity(_this));
    if (result == U_RESULT_OK) {
        destroy = u_entityDereference(u_entity(_this));
        /* if refCount becomes zero then this call
         * returns true and destruction can take place
         */
        if (destroy) {
            result = u_topicDeinit(_this);
            if (result == U_RESULT_OK) {
                u_entityDealloc(u_entity(_this));
            } else {
                OS_REPORT_2(OS_WARNING,
                            "u_topicFree",0,
                            "Operation u_topicDeinit failed: "
                            "Topic = 0x%x, result = %s.",
                            _this, u_resultImage(result));
                u_entityUnlock(u_entity(_this));
            }
        } else {
            u_entityUnlock(u_entity(_this));
        }
    } else {
        OS_REPORT_2(OS_WARNING,
                    "u_topicFree",0,
                    "Operation u_entityLock failed: "
                    "Topic = 0x%x, result = %s.",
                    _this, u_resultImage(result));
    }
    return result;
}
예제 #3
0
c_long
u_subscriberReaderCount(
    u_subscriber _this)
{
    c_long length = -1;
    u_result result;

    result = u_entityLock(u_entity(_this));
    if (result == U_RESULT_OK) {
        length = c_iterLength(_this->readers);
        u_entityUnlock(u_entity(_this));
    } else {
        OS_REPORT(OS_WARNING,
                  "u_subscriberRemoveReader",0,
                  "Failed to lock Subscriber.");
    }
    return length;
}
예제 #4
0
u_result
u_subscriberWalkReaders(
    u_subscriber _this,
    u_readerAction action,
    c_voidp actionArg)
{
    u_result result;

    result = u_entityLock(u_entity(_this));
    if (result == U_RESULT_OK) {
        c_iterWalkUntil(_this->readers, (c_iterAction)action, actionArg);
        u_entityUnlock(u_entity(_this));
    } else {
        OS_REPORT(OS_WARNING,
                  "u_subscriberWalkReaders",0,
                  "Failed to lock Subscriber.");
    }
    return result;
}
예제 #5
0
c_bool
u_subscriberContainsReader(
    u_subscriber _this,
    u_reader reader)
{
    c_bool found = FALSE;
    u_result result;

    result = u_entityLock(u_entity(_this));
    if (result == U_RESULT_OK) {
        found = c_iterContains(_this->readers,reader);
        u_entityUnlock(u_entity(_this));
    } else {
        OS_REPORT(OS_WARNING,
                  "u_subscriberContainsReader",0,
                  "Failed to lock Subscriber.");
    }
    return found;
}
예제 #6
0
u_result
u_subscriberAddReader(
    u_subscriber _this,
    u_reader reader)
{
    u_result result;

    result = u_entityLock(u_entity(_this));
    if (result == U_RESULT_OK) {
        _this->readers = c_iterInsert(_this->readers, reader);
        u_entityKeep(u_entity(_this));
        u_entityUnlock(u_entity(_this));
    } else {
        OS_REPORT(OS_WARNING,
                  "u_subscriberAddReader",0,
                  "Failed to lock Subscriber.");
    }
    return result;
}
예제 #7
0
u_result
u_subscriberRemoveReader(
    u_subscriber _this,
    u_reader reader)
{
    u_reader found;
    u_result result;

    result = u_entityLock(u_entity(_this));
    if (result == U_RESULT_OK) {
        found = c_iterTake(_this->readers,reader);
        if (found) {
            u_entityDereference(u_entity(_this));
        }
        u_entityUnlock(u_entity(_this));
    } else {
        OS_REPORT(OS_WARNING,
                  "u_subscriberRemoveReader",0,
                  "Failed to lock Subscriber.");
    }
    return result;
}
예제 #8
0
u_result
u_subscriberDeinit(
    u_subscriber _this)
{
    u_result result;
    u_dataReader reader;
    c_iter list;

    if (_this != NULL) {
        result = u_participantRemoveSubscriber(_this->participant,_this);
        if (result == U_RESULT_OK) {
            _this->participant = NULL;
            if (_this->readers) {
                list = _this->readers;
                _this->readers = NULL;
                u_entityUnlock(u_entity(_this));
                reader = c_iterTakeFirst(list);
                while (reader) {
                    /* Readers should not exist at this point!
                     * This loop corrects this erronous state.
                     */
                    result = u_dataReaderFree(reader);
                    u_entityDereference(u_entity(_this));
                    reader = c_iterTakeFirst(list);
                }
                c_iterFree(list);
                result = u_entityLock(u_entity(_this));
            }
            result = u_dispatcherDeinit(u_dispatcher(_this));
        }
    } else {
        OS_REPORT_1(OS_ERROR,
                    "u_subscriberDeinit",0,
                    "Illegal parameter: _this = 0x%x.",
                    _this);
        result = U_RESULT_ILL_PARAM;
    }
    return result;
}
예제 #9
0
c_iter
u_subscriberLookupReaders(
    u_subscriber _this,
    const c_char *topic_name)
{
    struct collect_readers_arg arg;
    u_result result;

    /* topic_name == NULL is treated as wildcard '*' */
    arg.topic_name = topic_name;
    arg.readers = NULL;

    result = u_entityLock(u_entity(_this));
    if (result == U_RESULT_OK) {
        c_iterWalk(_this->readers, collect_readers, &arg);
        u_entityUnlock(u_entity(_this));
    } else {
        OS_REPORT(OS_WARNING,
                  "u_subscriberLookupReaders",0,
                  "Failed to lock Subscriber.");
    }
    return arg.readers;
}