Пример #1
0
void
v_serviceFillNewGroups(
    v_service service)
{
    c_set newGroups;
    C_STRUCT(v_event) ge;
    v_group g;
    v_kernel kernel;
    c_iter groups = NULL;

    assert(service != NULL);
    assert(C_TYPECHECK(service, v_service));

    kernel = v_objectKernel(service);
    newGroups = (c_voidp)c_setNew(v_kernelType(kernel, K_GROUP));

    if (newGroups != NULL) {
        groups = v_groupSetSelectAll(kernel->groupSet);

        /* Take the first group and at the end notify the service about this new group.
         * But before push all other groups to the servive newGroup set so that only one trigger
         * is required to notify all groups.
         * The first group is automatically added to the newGroup set by the notification.
         * TODO : get rid of this mechanism.
         */
        ge.data = v_group(c_iterTakeFirst(groups));
        if (ge.data) {
            ge.kind = V_EVENT_NEW_GROUP;
            ge.source = v_observable(kernel);
            ospl_c_insert(newGroups, ge.data);
            while ((g = v_group(c_iterTakeFirst(groups))) != NULL) {
                ospl_c_insert(newGroups, g);
                c_free(g);
            }

            OSPL_BLOCK_EVENTS(service);
            c_free(service->newGroups);
            service->newGroups = (c_voidp)newGroups;
            OSPL_UNBLOCK_EVENTS(service);

            OSPL_TRIGGER_EVENT((service), &ge, NULL);
        }
        c_iterFree(groups);
    }
}
Пример #2
0
static void
addAllGroups(
    c_set newGroups,
    v_groupSet groupSet)
{
    c_iter groups = NULL;
    v_group g;

    assert(C_TYPECHECK(groupSet, v_groupSet));

    groups = v_groupSetSelectAll(groupSet);
    g = v_group(c_iterTakeFirst(groups));
    while (g != NULL) {
        c_insert(newGroups, g);
        c_free(g);
        g = v_group(c_iterTakeFirst(groups));
    }
    c_iterFree(groups);
}