c_iter v_serviceTakeNewGroups( v_service service) { c_iter result; v_group group; c_set newGroups; assert(service != NULL); assert(C_TYPECHECK(service, v_service)); result = c_iterNew(NULL); v_observerLock(v_observer(service)); newGroups = (c_set)v_observer(service)->eventData; if (newGroups != NULL) { group = v_group(c_take(newGroups)); while (group != NULL) { c_iterInsert(result, group); group = v_group(c_take(newGroups)); } } v_observerUnlock(v_observer(service)); return result; }
c_iter v_serviceTakeNewGroups( v_service service) { c_iter result; v_group group; c_set newGroups; assert(service != NULL); assert(C_TYPECHECK(service, v_service)); result = c_iterNew(NULL); OSPL_BLOCK_EVENTS(service); newGroups = service->newGroups; if (newGroups != NULL) { group = v_group(c_take(newGroups)); while (group != NULL) { c_iterInsert(result, group); group = v_group(c_take(newGroups)); } } OSPL_UNBLOCK_EVENTS(service); return result; }
void v_leaseManagerDeinit( v_leaseManager _this) { v_leaseAction lease; assert(C_TYPECHECK(_this, v_leaseManager)); c_mutexLock(&_this->mutex); c_free(_this->firstLeaseToExpire); _this->firstLeaseToExpire = NULL; lease = v_leaseAction(c_take(_this->leases)); while (lease != NULL) { c_free(lease); lease = v_leaseAction(c_take(_this->leases)); } c_free(_this->leases); _this->leases = NULL; _this->quit = TRUE; c_condBroadcast(&_this->cond); c_mutexUnlock(&_this->mutex); /* Note the condition _this->cond is deinitalised via c_free */ }
void v_collectionFree( v_collection c) { v_query q; assert(C_TYPECHECK(c,v_collection)); q = v_query(c_take(c->queries)); while (q != NULL) { /* The v_publicFree shouldn't be here, because it should be the * responsibility of the 'creator' of the query to have this * knowledge and perform the v_publicFree. The only thing that should be * required here is freeing the reference to the query by doing a * c_free. * * Because it is not exactly clear where the v_publicFree should be * performed, it is performed here for now. */ v_publicFree(v_public(q)); c_free(q); q = v_query(c_take(c->queries)); } v_observerFree(v_observer(c)); }
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); } }
void v_participantConnectNewGroup ( v_participant _this, v_event event) { v_group g; c_mutexLock(&_this->newGroupListMutex); g = c_take(_this->newGroupList); while (g) { c_mutexUnlock(&_this->newGroupListMutex); c_lockWrite(&_this->lock); c_walk(_this->entities, connectNewGroup, g); c_lockUnlock(&_this->lock); c_mutexLock(&_this->newGroupListMutex); g = c_take(_this->newGroupList); } c_mutexUnlock(&_this->newGroupListMutex); }
void v_leaseDeinit( v_lease lease) { v_leaseManager lm; assert(lease != NULL); assert(C_TYPECHECK(lease,v_lease)); if (lease != NULL) { lm = v_leaseManager(c_take(lease->observers)); while (lm != NULL) { c_free(lm); lm = v_leaseManager(c_take(lease->observers)); } c_free(lease->observers); lease->observers = NULL; } }
void v_waitsetDeinit( v_waitset _this) { v_waitsetEvent event; v_observable o; v_proxy found; v_handleResult result; void* userDataRemoved = NULL; assert(_this != NULL); assert(C_TYPECHECK(_this,v_waitset)); if (_this == NULL) { return; } v_waitsetLock(_this); found = c_take(_this->observables); while (found) { result = v_handleClaim(found->source,(v_object *)&o); if (result == V_HANDLE_OK) { v_observableRemoveObserver(o,v_observer(_this), &userDataRemoved); v_waitsetClearRemovedObserverPendingEvents(_this, userDataRemoved); result = v_handleRelease(found->source); } c_free(found); found = c_take(_this->observables); } /* wakeup blocking threads to evaluate new condition. */ /* remove all events */ while (v_waitsetEvent(v_waitsetEventList(_this)) != NULL) { event = v_waitsetEvent(v_waitsetEventList(_this)); v_waitsetEventList(_this) = event->next; event->next = NULL; c_free(event); } v_waitsetWakeup(_this, NULL, NULL); v_waitsetUnlock(_this); v_observerDeinit(v_observer(_this)); }
void v_participantFree( v_participant p) { v_message builtinMsg; v_participant found; v_entity e; v_kernel kernel; /* Not clear yet why builtin subscriber lock and participant lock are not taken now? * Also not clear why observer lock is not taken but is freed at the end! */ if (p != NULL) { assert(C_TYPECHECK(p,v_participant)); kernel = v_objectKernel(p); if (!v_observableRemoveObserver(v_observable(kernel),v_observer(p), NULL)) { if (v_participantName(p) != NULL) { OS_REPORT_1(OS_WARNING,"v_participantFree",0, "Participant '%s' cannot disconnect from Kernel events", v_participantName(p)); } else { OS_REPORT(OS_WARNING,"v_participantFree",0, "Participant cannot disconnect from Kernel events"); } } builtinMsg = v_builtinCreateParticipantInfo(kernel->builtin,p); v_writeDisposeBuiltinTopic(kernel, V_PARTICIPANTINFO_ID, builtinMsg); c_free(builtinMsg); builtinMsg = v_builtinCreateParticipantInfo(kernel->builtin,p); v_unregisterBuiltinTopic(kernel, V_PARTICIPANTINFO_ID, builtinMsg); c_free(builtinMsg); if (p->builtinSubscriber) { v_subscriberFree(p->builtinSubscriber); p->builtinSubscriber = NULL; } while ((e = c_take(p->entities)) != NULL) { switch (v_objectKind(e)) { case K_PUBLISHER: v_publisherFree(v_publisher(e)); break; case K_SUBSCRIBER: v_subscriberFree(v_subscriber(e)); break; case K_WAITSET: v_waitsetFree(v_waitset(e)); break; default: OS_REPORT_1(OS_WARNING,"Kernel Participant",0, "Illegal contained object (%s)", v_participantName(p)); break; } c_free(e); /* deref o since c_take will not */ } found = v_removeParticipant(kernel,p); assert(found == p); c_free(found); v_observerFree(v_observer(p)); } }