示例#1
0
v_writerSample
_v_writerSampleNew(
    v_writer writer,
    v_message message)
{
    v_writerSample sample;

    assert(writer != NULL);
    assert(C_TYPECHECK(writer,v_writer));
    assert(message);
    assert(C_TYPECHECK(message,v_message));

#ifdef _EXTENT_
    sample = v_writerSample(c_extentCreate(writer->sampleExtent));
#else
    sample = v_writerSample(c_new(writer->sampleField->type));
#endif

    if (sample) {
        v_writerSampleTemplate(sample)->message = c_keep(message);
        sample->next = NULL;
        sample->prev = NULL;
        sample->sequenceNumber = 1;
        sample->sentBefore = FALSE;
        v_writerSampleClear(sample);
    } else {
        OS_REPORT(OS_ERROR,
                  "v_writerSampleNew",0,
                  "Failed to allocate sample.");
    }

    assert(C_TYPECHECK(sample,v_writerSample));

    return sample;
}
示例#2
0
v_dataViewInstance
v_dataViewInstanceNew(
    v_dataView dataView,
    v_dataViewSample viewSample)
{
    v_dataViewInstance instance;

    assert(dataView);
    assert(viewSample);
    assert(C_TYPECHECK(dataView,v_dataView));
    assert(C_TYPECHECK(viewSample,v_dataViewSample));

    instance = v_dataViewInstance(c_new(dataView->instanceType));
    if (instance) {
        v_object(instance)->kernel = v_objectKernel(dataView);
        v_objectKind(instance) = K_DATAVIEWINSTANCE;
        v_instanceInit(v_instance(instance), v_entity(dataView));
        viewSample->next = viewSample;
        v_dataViewInstanceTemplate(instance)->sample = viewSample;
        instance->sampleCount = 1;

        v_stateSet(v_instanceState(instance),L_NEW);
        v_stateClear(v_readerSample(viewSample)->sampleState,L_READ);

        assert(C_TYPECHECK(instance,v_dataViewInstance));
        CHECK_INSTANCE(instance);
    } else {
        OS_REPORT(OS_FATAL, OS_FUNCTION, V_RESULT_INTERNAL_ERROR,
            "Failed to allocate v_dataViewInstance");
        assert(FALSE);
    }

    return instance;
}
示例#3
0
v_persistentSnapshotRequest
v_persistentSnapshotRequestNew(
    v_kernel kernel,
    const c_char* partition_expression,
    const c_char* topic_expression,
    const c_char* uri)
{
    v_persistentSnapshotRequest request;
    c_base base;

    request = c_new(v_kernelType(kernel,K_PERSISTENTSNAPSHOTREQUEST));
    if(request)
    {
        base = c_getBase(kernel);
        if(partition_expression)
        {
            request->partitionExpr = c_stringNew(base, partition_expression);
        }
        if(topic_expression)
        {
            request->topicExpr = c_stringNew(base, topic_expression);
        }
        if(uri)
        {
            request->uri = c_stringNew(base, uri);
        }
    } else {
        OS_REPORT(OS_ERROR,
                  "v_kernel::v_persistentSnapshotRequest",0,
                  "Failed to create v_persistentSnapshotRequest object.");
        assert(FALSE);
    }

    return request;
}
示例#4
0
v_dataViewSample
v_dataViewSampleNew(
    v_dataViewInstance instance,
    v_readerSample masterSample)
{
    v_dataView dataView;
    v_dataViewSample sample;

    assert(instance != NULL);
    assert(masterSample != NULL);
    assert(C_TYPECHECK(masterSample,v_readerSample));

    dataView = v_dataView(instance->dataView);
#ifdef _EXTENT_
    sample = v_dataViewSample(c_extentCreate(dataView->sampleExtent));
#else
    sample = v_dataViewSample(c_new(dataView->sampleType));
#endif
    if (sample) {
        v_readerSample(sample)->instance = (c_voidp)instance;
        v_readerSample(sample)->sampleState = 0;
        v_dataViewSampleList(sample)->next = NULL;
        v_dataViewSampleList(sample)->prev = NULL;
        sample->prev = NULL;
        v_dataViewSampleTemplate(sample)->sample = c_keep(masterSample);
    } else {
        OS_REPORT(OS_ERROR,
                  "v_dataViewSampleNew",0,
                  "Failed to allocate v_dataViewSample.");
    }
    return sample;
}
示例#5
0
文件: v_cache.c 项目: xrl/opensplice
v_cache
v_cacheNew (
    v_kernel kernel,
    c_type type,
    v_cacheKind kind)
{
    c_base base = NULL;
    c_type cache_t;
    v_cache cache = NULL;

    assert(C_TYPECHECK(cache,v_cache));
    assert(C_TYPECHECK(type,c_type));

    if (type) {
        base = c_getBase(type);
        if (base) {
            cache_t = c_keep(v_kernelType(kernel,K_CACHE));
            cache = c_new(cache_t);
            c_free(cache_t);
            if (cache) {
                cache->kind = kind;
                cache->itemType = c_keep(type);
                v_cacheNodeInit(v_cacheNode(cache));
            }
        }
    }
    return cache;
}
示例#6
0
cg_pipeline_cache_t *
_cg_pipeline_cache_new(cg_device_t *dev)
{
    cg_pipeline_cache_t *cache = c_new(cg_pipeline_cache_t, 1);
    unsigned long vertex_state;
    unsigned long layer_vertex_state;
    unsigned int fragment_state;
    unsigned int layer_fragment_state;

    cache->dev = dev;

    vertex_state = _cg_pipeline_get_state_for_vertex_codegen(dev);
    layer_vertex_state = CG_PIPELINE_LAYER_STATE_AFFECTS_VERTEX_CODEGEN;
    fragment_state = _cg_pipeline_get_state_for_fragment_codegen(dev);
    layer_fragment_state =
        _cg_pipeline_get_layer_state_for_fragment_codegen(dev);

    _cg_pipeline_hash_table_init(&cache->vertex_hash,
                                 dev,
                                 vertex_state,
                                 layer_vertex_state,
                                 "vertex shaders");
    _cg_pipeline_hash_table_init(&cache->fragment_hash,
                                 dev,
                                 fragment_state,
                                 layer_fragment_state,
                                 "fragment shaders");
    _cg_pipeline_hash_table_init(&cache->combined_hash,
                                 dev,
                                 vertex_state | fragment_state,
                                 layer_vertex_state | layer_fragment_state,
                                 "programs");

    return cache;
}
示例#7
0
int
v_messageExtCdrDeserializeNoAllocTime (
    int (*f) (void *dst, const struct sd_cdrInfo *ci, os_uint32 sz, const void *src),
    v_message *dst,
    const struct v_messageExtCdrInfo *xci,
    os_uint32 sz,
    const void *src)
{
    struct v_messageExtCdrTmp tmp;
    struct v_messageExt_s xmsg;
    v_message vmsg;
    int rc;
    if ((vmsg = c_new (xci->vmsgType)) == NULL) {
        return SD_CDR_OUT_OF_MEMORY;
    }
    tmp.h = &xmsg;
    tmp.d = vmsg + 1;
    if ((rc = f(&tmp, xci->ci, sz, src)) < 0) {
        c_free(vmsg);
        return rc;
    }
    v_messageExtConvertHeaderFromExtNoAllocTime(vmsg, &xmsg);
    *dst = vmsg;
    return 0;
}
示例#8
0
v_deadLineInstanceList
v_deadLineInstanceListNew(
    c_base base,
    v_leaseManager leaseManager,
    v_duration leaseDuration,
    v_leaseActionId actionId,
    v_public o)
{
    v_deadLineInstanceList list;
    c_type type;

    assert(C_TYPECHECK(leaseManager,v_leaseManager));
    assert(C_TYPECHECK(o,v_public));

    type = c_resolve(base, "kernelModule::v_deadLineInstanceList");
    assert(type);
    list = c_new(type);
    c_free(type);
    if (list) {
        v_objectKind(list) = K_DEADLINEINSTANCE;
        v_instanceInit(v_instance(list));
        list->leaseManager = c_keep(leaseManager);
        list->leaseDuration = leaseDuration;
        list->deadlineLease = NULL;
        list->actionObject = o; /* no keep, since actionObject is onwer of v_deadLineInstanceList */
        list->actionId = actionId;
    } else {
        OS_REPORT(OS_ERROR,
                  "v_deadLineInstanceListNew",0,
                  "Failed to allocate v_deadLineInstanceList.");
    }

    return list;
}
v_historicalDataRequest
v_historicalDataRequestNew(
    v_kernel kernel,
    c_char* filter,
    c_char* params[],
    c_ulong nofParams,
    c_time minSourceTime,
    c_time maxSourceTime,
    struct v_resourcePolicy *resourceLimits)
{
    v_historicalDataRequest request;
    c_ulong i;
    c_type type;
    c_base base;

    request = c_new(v_kernelType(kernel,K_HISTORICALDATAREQUEST));

    if (request) {
        if(filter){
            base            = c_getBase(kernel);
            request->filter = c_stringNew(base, filter);

            if(params){
                type                  = c_string_t(base);
                request->filterParams = c_arrayNew(type, nofParams);

                for(i=0; i<nofParams; i++){
                    request->filterParams[i] = c_stringNew(base, params[i]);
                }
            } else {
                request->filterParams = NULL;
            }
        } else {
            request->filter       = NULL;
            request->filterParams = NULL;
        }
        if ((minSourceTime.seconds     == C_TIME_INVALID.seconds) &&
            (minSourceTime.nanoseconds == C_TIME_INVALID.nanoseconds)) {
            request->minSourceTimestamp = C_TIME_ZERO;
        } else {
            request->minSourceTimestamp  = minSourceTime;
        }
        if ((maxSourceTime.seconds     == C_TIME_INVALID.seconds) &&
            (maxSourceTime.nanoseconds == C_TIME_INVALID.nanoseconds)) {
            request->maxSourceTimestamp = C_TIME_INFINITE;
        } else {
            request->maxSourceTimestamp  = maxSourceTime;
        }
        request->resourceLimits.max_samples              = resourceLimits->max_samples;
        request->resourceLimits.max_instances            = resourceLimits->max_instances;
        request->resourceLimits.max_samples_per_instance = resourceLimits->max_samples_per_instance;
    } else {
        OS_REPORT(OS_ERROR,
                  "v_historicalDataRequestNew",0,
                  "Failed to allocate request.");
        assert(FALSE);
    }

    return request;
}
示例#10
0
d_sample
d_groupInfoSampleNew (
    d_groupInfo _this,
    d_instance instance,
    v_message msg)
{
    d_sample sample;
    v_message mmfMessage;

    sample = d_sample(c_new(_this->topic->sampleType));

    if (sample) {
        c_cloneIn(_this->topic->messageType, msg, (c_voidp*)&(mmfMessage));
        d_sampleTemplate(sample)->message = mmfMessage;
        sample->instance = instance;
        sample->older = NULL;
        sample->newer = NULL;
    } else {
        OS_REPORT(OS_ERROR,
              "d_groupInfoSampleNew",0,
              "Failed to allocate sample.");
        assert(FALSE);
    }
    return sample;
}
示例#11
0
v_messageEOTExt
v_messageEOTExtCopyToExtType (
    const struct v_messageEOT_s *vmsg)
{
    c_type xmsgType = c_resolve(c_getBase((c_object)vmsg), "kernelModule::v_messageEOTExt");
    v_messageEOTExt xmsg;
    xmsg = c_new (xmsgType);
    c_free(xmsgType);
    v_messageEOTExtConvertToExtNoAllocTime (xmsg, vmsg);
    return xmsg;
}
示例#12
0
v_messageExt
v_messageExtCopyToExtType (
    c_type xmsgType,
    const struct v_message_s *vmsg)
{
    v_messageExt xmsg;
    xmsg = c_new (xmsgType);
    v_messageExtConvertHeaderToExt (xmsg, vmsg);
    memcpy (xmsg + 1, vmsg + 1, xmsgType->size - sizeof (*xmsg));
    return xmsg;
}
示例#13
0
文件: v_cache.c 项目: xrl/opensplice
v_cacheNode
v_cacheNodeNew (
    v_cache cache)
{
    v_cacheNode node;

    assert(C_TYPECHECK(cache,v_cache));

    node = c_new(cache->itemType);
    v_cacheNodeInit(node);
    return node;
}
示例#14
0
v_qos
v_qosCreate(
    v_kernel kernel,
    v_qosKind kind)
{
    v_qos qos;
    c_base base;
    c_type type;

    assert(kernel != NULL);
    assert(C_TYPECHECK(kernel,v_kernel));

    base = c_getBase(c_object(kernel));

#define _CASE_(l,t) case l: type = c_resolve(base,t); break

    switch (kind) {
    _CASE_(V_PARTITION_QOS,        "kernelModule::v_partitionQos");
    _CASE_(V_PARTICIPANT_QOS,   "kernelModule::v_participantQos");
    _CASE_(V_TOPIC_QOS,         "kernelModule::v_topicQos");
    _CASE_(V_WRITER_QOS,        "kernelModule::v_writerQos");
    _CASE_(V_READER_QOS,        "kernelModule::v_readerQos");
    _CASE_(V_PUBLISHER_QOS,     "kernelModule::v_publisherQos");
    _CASE_(V_SUBSCRIBER_QOS,    "kernelModule::v_subscriberQos");
    _CASE_(V_INDEX_QOS,         "kernelModule::v_indexQos");
    _CASE_(V_WRITERHISTORY_QOS, "kernelModule::v_writerHistoryQos");
    _CASE_(V_GROUPHISTORY_QOS,  "kernelModule::v_groupHistoryQos");
    _CASE_(V_VIEW_QOS,          "kernelModule::v_viewQos");
    _CASE_(V_DATAVIEW_QOS,      "kernelModule::v_dataViewQos");
    _CASE_(V_KERNEL_QOS,        "kernelModule::v_kernelQos");
    default:
        OS_REPORT_1(OS_ERROR,"v_qos::Create",0,
                    "Illegal Qos kind specified (%s)",
                    v_qosKindImage(kind));
        return NULL;
    }

    qos = v_qos(c_new(type));
    c_free(type);
    if (qos) {
        qos->kind = kind;
    } else {
        OS_REPORT(OS_ERROR,
                  "v_qosCreate",0,
                  "Failed to allocate qos.");
        assert(FALSE);
    }

    return qos;

#undef _CASE_
}
示例#15
0
d_storeResult
d_groupInfoBackup(
    d_groupInfo _this,
    const d_store store,
    d_groupInfo* backup)
{
    c_base base;
    c_type groupInfoType, instanceType;
    c_string keyExpr;
    d_storeResult result;

    assert(_this);
    assert(backup);

    base = c_getBase(_this->kernel);
    groupInfoType = c_resolve(base,"durabilityModule2::d_groupInfo");
    *backup = d_groupInfo(c_new(groupInfoType));
    c_free(groupInfoType);

    if (*backup) {
        (*backup)->kernel = _this->kernel; /* Unmanaged pointer */
        (*backup)->topic = c_keep(_this->topic);
        (*backup)->partition = c_keep(_this->partition);
        (*backup)->quality = _this->quality;
        (*backup)->completeness = _this->completeness;

        instanceType = d_topicInfoGetInstanceType(_this->topic);
        keyExpr = d_topicInfoGetInstanceKeyExpr(_this->topic);

        (*backup)->instances = _this->instances; /*Here's the trick */
        _this->instances = c_tableNew(instanceType, keyExpr);

        c_free(keyExpr);
        c_free(instanceType);

        if(_this->instances){
            result = D_STORE_RESULT_OK;
        } else {
            _this->instances = (*backup)->instances;

            (*backup)->instances = NULL;
            c_free(*backup);
            *backup = NULL;

            result = D_STORE_RESULT_OUT_OF_RESOURCES;
        }
    } else {
        assert(FALSE);
        result = D_STORE_RESULT_OUT_OF_RESOURCES;
    }
    return result;
}
示例#16
0
c_scope
c_scopeNew(
    c_base base)
{
    c_scope o;

    o = c_scope(c_new(c_resolve(base,"c_scope")));
    if (o) {
        c_scopeInit(o);
    }

    return o;
}
示例#17
0
d_storeMMFKernel
d_storeMMFKernelNew (
    c_base base,
    const c_char *name)
{
    d_storeMMFKernel kernel, found;
    c_type type;
    c_bool success;

    /* load meta-data */
    success = loadkernelModule(base);
    assert(success);

    success = loaddurabilityModule2(base);
    assert(success);

    /* create storeKernel */
    type = c_resolve(base,"durabilityModule2::d_storeMMFKernel");
    kernel = (d_storeMMFKernel)c_new(type);
    c_free(type);

     if(kernel) {
        /* Init storeKernel members */
        /* groups is a table of d_groupInfo with topic+partition as key */
        type = c_resolve(base,"durabilityModule2::d_groupInfo");
        assert(type);
        kernel->groups = c_tableNew(type, "partition,topic.name");
        kernel->backup = c_tableNew(type, "partition,topic.name");
        c_free(type);

        type = c_resolve(base,"durabilityModule2::d_topicInfo");
        assert(type);
        kernel->topics = c_tableNew(type, "name");
        c_free(type);

        type = c_resolve(base,"durabilityModule2::d_nameSpaceInfo");
        assert(type);
        kernel->nameSpaces = c_tableNew(type, "name");
        c_free(type);

        /* bind storeKernel */
        found = ospl_c_bind(kernel, name);
        assert(found == kernel);
     } else {
         OS_REPORT(OS_ERROR,
                   "d_storeMMFKernelNew",0,
                   "Failed to allocate kernel.");
         found = NULL;
     }
     return found;
}
示例#18
0
d_groupInfo
d_groupInfoNew (
    const d_storeMMFKernel kernel,
    const d_topicInfo topic,
    const d_group dgroup)
{
    d_groupInfo group;
    c_base base;
    c_char* partition;
    c_type instanceType, groupInfoType;
    c_char *keyExpr;

    if(kernel && topic && dgroup){
        base = c_getBase(kernel);
        groupInfoType = c_resolve(base,"durabilityModule2::d_groupInfo");
        group = d_groupInfo(c_new(groupInfoType));
        c_free(groupInfoType);

        if (group) {
            group->kernel = kernel; /* Unmanaged pointer */
            group->topic = c_keep(topic);

            partition = d_groupGetPartition(dgroup);
            group->partition = c_stringNew(base, partition);
            os_free(partition);

            group->quality = d_groupGetQuality(dgroup);
            group->completeness = d_groupGetCompleteness(dgroup);

            instanceType = d_topicInfoGetInstanceType(topic);
            keyExpr = d_topicInfoGetInstanceKeyExpr(topic);
            group->instances = c_tableNew(instanceType, keyExpr);
            c_free(keyExpr);
            c_free(instanceType);
        } else {
            OS_REPORT(OS_ERROR,
                      "d_groupInfoNew",0,
                      "Failed to allocate d_groupInfo.");
            assert(FALSE);
            group = NULL;
        }
    } else {
        OS_REPORT(OS_ERROR,
                  "d_groupInfoNew",0,
                  "Illegal constructor parameter.");
        group = NULL;
    }
    return group;
}
示例#19
0
cg_sampler_cache_t *
_cg_sampler_cache_new(cg_device_t *dev)
{
    cg_sampler_cache_t *cache = c_new(cg_sampler_cache_t, 1);

    /* No reference is taken on the context because it would create a
       circular reference */
    cache->dev = dev;

    cache->hash_table_gl =
        c_hash_table_new(hash_sampler_state_gl, sampler_state_equal_gl);
    cache->hash_table_cg =
        c_hash_table_new(hash_sampler_state_cg, sampler_state_equal_cg);
    cache->next_fake_sampler_object_number = 1;

    return cache;
}
示例#20
0
static d_instance
d_instanceNew(
    d_groupInfo groupInfo,
    const v_groupAction action)
{
    d_instance instance;
    c_type type;
    c_long nrOfKeys, i;
    c_array messageKeyList, instanceKeyList;

    instanceKeyList = c_tableKeyList(groupInfo->instances);
    type = c_subType(groupInfo->instances);
    instance = d_instance(c_new(type));
    c_free(type);

    if(instance){
        /*
         * copy the key value of the message into the newly created instance.
         */
        messageKeyList = v_topicMessageKeyList(v_groupTopic(action->group));
        nrOfKeys = c_arraySize(messageKeyList);
        assert(nrOfKeys == c_arraySize(instanceKeyList));

        for (i=0;i<nrOfKeys;i++) {
            c_fieldCopy(messageKeyList[i],action->message,
                        instanceKeyList[i], instance);
        }
        c_free(instanceKeyList);

        d_instanceSetHead(instance, NULL);
        d_instanceSetTail(instance, NULL);

        instance->messageCount = 0;
        instance->count = 0;
        instance->state = 0;

        v_stateSet(instance->state, L_EMPTY);
    } else {
        OS_REPORT(OS_ERROR,
                  "d_instanceNew",0,
                  "Failed to allocate instance.");
        assert(FALSE);
    }
    return instance;
}
示例#21
0
d_storeResult
d_storeMMFKernelMarkNameSpaceComplete(
    d_storeMMFKernel kernel,
    const d_nameSpace nameSpace,
    const c_bool isComplete)
{
    d_nameSpaceInfo nsInfo;
    c_type type;
    c_char* name;
    c_value keyValues[1];
    d_storeResult result;

    if(kernel && nameSpace){
        name = d_nameSpaceGetName(nameSpace);
        keyValues[0] = c_stringValue((c_string)name);
        nsInfo = c_tableFind(kernel->nameSpaces, keyValues);

        if(nsInfo){
            nsInfo->complete = isComplete;
            result = D_STORE_RESULT_OK;
        } else {
            type = c_resolve(c_getBase(kernel),
                    "durabilityModule2::d_nameSpaceInfo");
            nsInfo = (d_nameSpaceInfo)c_new(type);
            c_free(type);

            if (nsInfo) {
                nsInfo->name = c_stringNew(c_getBase(kernel), name);
                nsInfo->complete = isComplete;
                c_tableInsert(kernel->nameSpaces, nsInfo);
                c_free(nsInfo);
                result = D_STORE_RESULT_OK;
            } else {
                OS_REPORT(OS_ERROR,
                      "d_storeMMFKernelMarkNameSpaceComplete",0,
                      "Failed to allocate nameSpaceInfo.");
                result = D_STORE_RESULT_OUT_OF_RESOURCES;
            }
        }
    } else {
        result = D_STORE_RESULT_ILL_PARAM;
    }
    return result;
}
示例#22
0
v_partitionInterest
v_partitionInterestNew(
    v_kernel kernel,
    const char *partitionExpression)
{
    v_partitionInterest result = NULL;


    result = c_new(v_kernelType(kernel, K_DOMAININTEREST));
    if (result) {
        result->expression = c_stringNew(c_getBase(c_object(kernel)), partitionExpression);
    } else {
        OS_REPORT(OS_ERROR,
                  "v_partitionInterestNew",0,
                  "Failed to allocate partition interest.");
    }

    return result;
}
示例#23
0
v_dataViewInstance
v_dataViewInstanceNew(
    v_dataView dataView,
    v_readerSample sample)
{
    v_dataViewInstance instance;
    v_dataViewSample viewSample;

    assert(dataView);
    assert(sample);
    assert(C_TYPECHECK(dataView,v_dataView));
    assert(C_TYPECHECK(sample,v_readerSample));

    instance = v_dataViewInstance(c_new(dataView->instanceType));
    if (instance) {
        v_object(instance)->kernel = v_objectKernel(dataView);
        v_objectKind(instance) = K_DATAVIEWINSTANCE;
        instance->dataView = (c_voidp)dataView;

        viewSample = v_dataViewSampleNew(instance,sample);
        if (viewSample) {
            v_dataViewInstanceTemplate(instance)->sample = viewSample;
            viewSample->next = NULL;
            viewSample->prev = NULL;
            v_readerSampleAddViewSample(sample,viewSample);
            instance->sampleCount = 1;

            v_stateSet(instance->instanceState,L_NEW);
            v_stateClear(v_readerSample(viewSample)->sampleState,L_READ);

            assert(C_TYPECHECK(instance,v_dataViewInstance));
            v_dataViewNotifyDataAvailable(dataView, viewSample);
        }
        CHECK_INSTANCE(instance);
    } else {
        OS_REPORT(OS_ERROR,
                  "v_dataViewInstanceNew",0,
                  "Failed to allocate v_dataViewInstancem");
        assert(FALSE);
    }

    return instance;
}
示例#24
0
/**************************************************************
 * constructor/destructor
 **************************************************************/
v_lifespanAdmin
v_lifespanAdminNew(
    v_kernel kernel)
{
    v_lifespanAdmin admin;

    admin = NULL;
    admin = c_new(c_resolve(c_getBase(kernel), "kernelModule::v_lifespanAdmin"));
    if (admin != NULL) {
        admin->sampleCount = 0;
        admin->head = NULL;
        admin->tail = NULL;
    } else {
        OS_REPORT(OS_ERROR,
                  "v_lifespanAdminNew",0,
                  "Failed to allocate lifespan admin.");
        assert(FALSE);
    }
    return admin;
}
示例#25
0
v_object
v_new(
    v_kernel kernel,
    c_type type)
{
    v_object o;
    c_type t;
    c_long i;

    assert(C_TYPECHECK(kernel,v_kernel));
    assert(C_TYPECHECK(type,c_type));

    if (type == NULL) {
        return NULL;
    }
    o = c_new(type);
    if (o) {
        o->kernel = kernel;
        t = type;
        while (t != NULL) {
            for (i=0;i<K_TYPECOUNT;i++) {
                if (t == kernel->type[i]) {
                    o->kind = i;
                    return o;
                }
            }
            if (c_baseObject(t)->kind == M_CLASS) {
                t = c_type(c_class(t)->extends);
            } else {
                t = NULL;
            }
        }
        o->kind = K_OBJECT;
    } else {
        OS_REPORT(OS_ERROR,
                  "v_new",0,
                  "Failed to create kernel object.");
        assert(FALSE);
    }
    return o;
}
示例#26
0
v_rnrStorageStatistics
v_rnrStorageStatisticsNew(
    v_kernel k,
    const c_char *name)
{
    v_rnrStorageStatistics _this;
    c_string storageName;
    c_type type;

    assert(k && name);
    assert(C_TYPECHECK(k, v_kernel));

    type = c_resolve(c_getBase(k), "kernelModule::v_rnrStorageStatistics");

    _this = v_rnrStorageStatistics(c_new(type));
    storageName = c_stringNew(c_getBase(c_object(k)), name);
    c_free(type);

    v_rnrStorageStatisticsInit(_this, k, storageName);
    return _this;
}
示例#27
0
v_deliveryWaitList
v_deliveryWaitListNew(
    v_deliveryGuard _this,
    v_message msg)
{
    v_deliveryWaitList waitlist = NULL;
    v_deliveryWaitList found;
    c_type type;

    assert(C_TYPECHECK(_this,v_deliveryGuard));

    if (_this) {
        /* lookup or create a writer specific admin.
         */
        type = c_subType(_this->waitlists);
        waitlist = c_new(type);
        c_free(type);
        if (waitlist) {
            waitlist->sequenceNumber = msg->sequenceNumber;
            waitlist->readerGID = copyReaderGIDsFromPublications(_this);
            waitlist->guard = _this;
            c_mutexInit(&waitlist->mutex, SHARED_MUTEX);
            c_condInit(&waitlist->cv, &waitlist->mutex, SHARED_COND);
        }
        found = c_tableInsert(_this->waitlists, waitlist);
        if (found != waitlist) {
            /* This should not happen! */
            OS_REPORT(OS_ERROR,
                      "v_deliveryWaitListNew",0,
                      "detected inconsistent waitlist admin.");
            c_free(waitlist);
            waitlist = NULL;
        }
    } else {
        OS_REPORT(OS_ERROR,
                  "v_deliveryWaitListNew",0,
                  "Operation failed: illegal parameter (_this == NULL).");
    }
    return waitlist;
}
示例#28
0
v_object
v_objectNew(
    v_kernel kernel,
    v_kind kind)
{
    v_object o;

    assert(C_TYPECHECK(kernel,v_kernel));

    o = c_new(v_kernelType(kernel,kind));
    if (o) {
        assert(C_TYPECHECK(o,v_object));
        o->kind = kind;
        o->kernel = kernel;
    } else {
        OS_REPORT(OS_ERROR,
                  "v_objectNew",0,
                  "Failed to create kernel object.");
        assert(FALSE);
    }
    return o;
}
示例#29
0
static v_waitsetEvent
v_waitsetEventNew(
    v_waitset _this)
{
    v_kernel k;
    v_waitsetEvent event;

    if (_this->eventCache) {
        event = _this->eventCache;
        _this->eventCache = event->next;
    } else {
        k = v_objectKernel(_this);
        event = c_new(v_kernelType(k,K_WAITSETEVENT));

        if (!event) {
            OS_REPORT(OS_ERROR,
                      "v_waitsetEventNew",0,
                      "Failed to allocate event.");
        }
    }
    return event;
}
示例#30
0
v_handleServer
v_handleServerNew (
    c_base base)
{
    v_handleServer server;
    c_type type;

    assert(base != NULL);

    type = c_resolve(base,"kernelModule::v_handleServer");
    server = c_new(type);
    c_free(type);
    if (server) {
        type = c_resolve(base,"kernelModule::v_handleInfoList");
        server->handleInfos = c_arrayNew(type,NROFCOL);
#ifdef DDS_1958_CANNOT_CALL_REGISTERED_FUNC_PTR_FROM_DIFF_PROCESS
        server->lowMemWarningCount = 0;
#endif
        c_free(type);
        if (server->handleInfos) {
            server->firstFree = NOHANDLE;
            server->lastIndex = NOHANDLE;
            server->suspended = FALSE;
            c_mutexInit(&server->mutex,SHARED_MUTEX);
            c_baseOnOutOfMemory(base, disableHandleServer,server);
            c_baseOnLowOnMemory(base, issueLowMemoryWarning, server);
        } else {
            c_free(server);
            server = NULL;
            OS_REPORT(OS_ERROR,"v_handleServerNew",0,
                      "Failed to allocate handle info records");
        }
    } else {
        OS_REPORT(OS_ERROR,"v_handleServerNew",0,
                  "Failed to allocate handle server");
    }
    return server;
}