QcChunkTickets Class
Load tickets of circuits (decision E-376): chunks loaded for a while although no player is near. More...
| Header: | #include <server/chunks/QcChunkTickets.h> |
Public Types
Public Functions
| bool | canGive() const |
| quint64 | changes() const |
| QList<QcChunkPos> | chunks() const |
| void | clear() |
| bool | contains(QcChunkPos chunk) const |
| qsizetype | count() const |
| void | expire(quint64 now, const std::function<bool (QcChunkPos)> &isLoaded, const std::function<Use (QcChunkPos)> &use = {}) |
| quint64 | given() const |
| const QcChunkTickets::Limits & | limits() const |
| quint64 | refused() const |
| bool | request(QcChunkPos chunk, quint64 now, qsizetype weight = 1, bool retry = false) |
| void | setLimits(const QcChunkTickets::Limits &limits) |
| qsizetype | weight() const |
Detailed Description
Circuits ask for one when a signal reaches a part of its line that is not loaded (QcCircuitState::waitingOn), so a long line switches a far door. Tickets are bounded per tick and in the world (QcServerLimits) and last a fixed number of ticks. A ticket weighs as many chunks as the group it loads (decision E-375), so total bounds the chunks tickets keep loaded; a chunk asked for again while it has a ticket keeps its first one, so a clock cannot keep a chunk loaded forever by itself.
Member Type Documentation
enum class QcChunkTickets::Use
What a signal does in a chunk with a ticket: nothing, passes through (changes or scheduled ticks) or waits there for the next chunk of its way.
| Constant | Value | Description |
|---|---|---|
QcChunkTickets::Use::Free | 0 | No signal does anything there. |
QcChunkTickets::Use::Busy | 1 | A signal passes through. |
QcChunkTickets::Use::Waiting | 2 | A signal waits there for the next chunk of its way. |
Member Function Documentation
bool QcChunkTickets::canGive() const
Returns whether tickets can be given at all (limits above zero).
quint64 QcChunkTickets::changes() const
Returns the count of tickets given or ended (QcChunkLoading recomputes the needed chunks on a change).
QList<QcChunkPos> QcChunkTickets::chunks() const
Returns the chunks with a ticket.
void QcChunkTickets::clear()
Ends every ticket.
bool QcChunkTickets::contains(QcChunkPos chunk) const
Returns whether chunk has a ticket.
qsizetype QcChunkTickets::count() const
Returns the number of tickets.
void QcChunkTickets::expire(quint64 now, const std::function<bool (QcChunkPos)> &isLoaded, const std::function<Use (QcChunkPos)> &use = {})
Ends the tickets that ran out at tick now; starts the budget of a new tick. isLoaded tells whether a chunk is loaded, use what a signal does in it. A ticket's time counts from the tick its chunk is loaded (reading it may take a while), so it lasts ticks loaded ticks. A signal is never taken into storage halfway (decision E-378): while one waits in the chunk the ticket stays, while one passes through it lasts up to ticks more after that.
quint64 QcChunkTickets::given() const
Returns the tickets given since the world opened.
const QcChunkTickets::Limits &QcChunkTickets::limits() const
Returns the limits.
See also setLimits().
quint64 QcChunkTickets::refused() const
Returns the tickets refused by the limits since the world opened.
bool QcChunkTickets::request(QcChunkPos chunk, quint64 now, qsizetype weight = 1, bool retry = false)
Gives chunk a ticket at tick now for a group of weight chunks. Returns false when the limits refuse it. A chunk with a ticket keeps it. A refusal counts unless retry (a wish refused before, asked again).
void QcChunkTickets::setLimits(const QcChunkTickets::Limits &limits)
Sets limits.
See also limits().
qsizetype QcChunkTickets::weight() const
Returns the chunks the tickets load, their groups counted whole.