void new_shape(shape * s, bucket * b){ s->x = 3; s->y = -1; s->type = b->bucket1[0]; s->rotation = 0; //check if second bucket is empty if(b->bucket1[7] == -1) refill_bucket(b); //shuffle buckets int i; for(i = 0; i < 13; i++) b->bucket1[i] = b->bucket1[i+1]; b->bucket1[13] = -1; }
static void rate_limit_periodic_cb(void *rl_) { struct rate_limiter *rl = rl_; int i; /* Drain some packets out of the bucket if possible, but limit the number * of iterations to allow other code to get work done too. */ refill_bucket(rl); for (i = 0; rl->n_queued && get_token(rl) && i < 50; i++) { /* Use a small, arbitrary limit for the amount of queuing to do here, * because the TCP connection is responsible for buffering and there is * no point in trying to transmit faster than the TCP connection can * handle. */ struct ofpbuf *b = dequeue_packet(rl); if (rconn_send_with_limit(rl->remote_rconn, b, &rl->n_txq, 10)) { rl->n_tx_dropped++; } } }