diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2016-11-01 23:11:27 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2016-11-02 10:12:26 -0400 |
commit | 8025921fc89bc6be7c92acb43b47bf7a46a38bb8 (patch) | |
tree | 99bb220ee837ca83c4c3c5c919eda34de947b48f /klippy/stepcompress.c | |
parent | ff6fef927adca88b5c7749958ccfc806e4b9477c (diff) | |
download | kutter-8025921fc89bc6be7c92acb43b47bf7a46a38bb8.tar.gz kutter-8025921fc89bc6be7c92acb43b47bf7a46a38bb8.tar.xz kutter-8025921fc89bc6be7c92acb43b47bf7a46a38bb8.zip |
stepcompress: Invert the meaning of the min_clock flag
Use a non-zero qm->min_clock value to indicate that the command uses
the move queue and to also store the clock of when that move queue
item will be released.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/stepcompress.c')
-rw-r--r-- | klippy/stepcompress.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/klippy/stepcompress.c b/klippy/stepcompress.c index f628f7e4..7a4bfbbe 100644 --- a/klippy/stepcompress.c +++ b/klippy/stepcompress.c @@ -360,7 +360,7 @@ stepcompress_flush(struct stepcompress *sc, uint64_t move_clock) sc->queue_step_msgid, sc->oid, move.interval, move.count, move.add }; struct queue_message *qm = message_alloc_and_encode(msg, 5); - qm->req_clock = sc->last_step_clock; + qm->min_clock = qm->req_clock = sc->last_step_clock; list_add_tail(&qm->node, &sc->msg_queue); uint32_t addfactor = move.count*(move.count-1)/2; @@ -389,7 +389,6 @@ stepcompress_queue_msg(struct stepcompress *sc, uint32_t *data, int len) stepcompress_flush(sc, UINT64_MAX); struct queue_message *qm = message_alloc_and_encode(data, len); - qm->min_clock = -1; qm->req_clock = sc->last_step_clock; list_add_tail(&qm->node, &sc->msg_queue); } @@ -483,7 +482,6 @@ steppersync_flush(struct steppersync *ss, uint64_t move_clock) // Order commands by the reqclock of each pending command struct list_head msgs; list_init(&msgs); - uint64_t min_clock = ss->move_clocks[0]; for (;;) { // Find message with lowest reqclock uint64_t req_clock = MAX_CLOCK; @@ -499,17 +497,17 @@ steppersync_flush(struct steppersync *ss, uint64_t move_clock) } } } - if (!qm || (!qm->min_clock && req_clock > move_clock)) + if (!qm || (qm->min_clock && req_clock > move_clock)) break; - // Set the min_clock for this command - if (!qm->min_clock) { - qm->min_clock = min_clock; - heap_replace(ss, req_clock); - min_clock = ss->move_clocks[0]; - } else { - qm->min_clock = min_clock; - } + uint64_t next_avail = ss->move_clocks[0]; + if (qm->min_clock) + // The qm->min_clock field is overloaded to indicate that + // the command uses the 'move queue' and to store the time + // that move queue item becomes available. + heap_replace(ss, qm->min_clock); + // Reset the min_clock to its normal meaning (minimum transmit time) + qm->min_clock = next_avail; // Batch this command list_del(&qm->node); |