static DPReceivePeer * find_peer (DPReceiveDevice *o, peerid_t id) { for (LinkedList1Node *node = LinkedList1_GetFirst(&o->peers_list); node; node = LinkedList1Node_Next(node)) { DPReceivePeer *p = UPPER_OBJECT(node, DPReceivePeer, list_node); if (p->peer_id == id) { return p; } } return NULL; }
BPending * BPendingGroup_PeekJob (BPendingGroup *g) { DebugObject_Access(&g->d_obj); LinkedList1Node *node = LinkedList1_GetLast(&g->jobs); if (!node) { return NULL; } return UPPER_OBJECT(node, BPending, pending_node); }
static BProcess * find_process (BProcessManager *o, pid_t pid) { LinkedList2Iterator it; LinkedList2Iterator_InitForward(&it, &o->processes); LinkedList2Node *node; while (node = LinkedList2Iterator_Next(&it)) { BProcess *p = UPPER_OBJECT(node, BProcess, list_node); if (p->pid == pid) { LinkedList2Iterator_Free(&it); return p; } } return NULL; }
static void schedule (PacketPassFifoQueue *o) { ASSERT(!o->freeing) ASSERT(!o->sending_flow) ASSERT(!LinkedList1_IsEmpty(&o->waiting_flows_list)) ASSERT(!BPending_IsSet(&o->schedule_job)) // get first waiting flow PacketPassFifoQueueFlow *flow = UPPER_OBJECT(LinkedList1_GetFirst(&o->waiting_flows_list), PacketPassFifoQueueFlow, waiting_flows_list_node); ASSERT(flow->queue == o) ASSERT(flow->is_waiting) // remove it from queue LinkedList1_Remove(&o->waiting_flows_list, &flow->waiting_flows_list_node); flow->is_waiting = 0; // send PacketPassInterface_Sender_Send(o->output, flow->waiting_data, flow->waiting_len); o->sending_flow = flow; }
void BPendingGroup_ExecuteJob (BPendingGroup *g) { ASSERT(!LinkedList1_IsEmpty(&g->jobs)) DebugObject_Access(&g->d_obj); // get a job LinkedList1Node *node = LinkedList1_GetLast(&g->jobs); BPending *p = UPPER_OBJECT(node, BPending, pending_node); ASSERT(p->pending) // remove from jobs list LinkedList1_Remove(&g->jobs, &p->pending_node); // set not pending p->pending = 0; // execute job p->handler(p->user); return; }