class resolver
Defined at line 1551 of file ../../sdk/lib/fit-promise/include/lib/fpromise/promise.h
The resolver mechanism implements a lightweight form of reference
counting for tasks that have been suspended.
When a suspended task is created in a non-empty state, it receives
a pointer to a resolver interface and a ticket. The ticket is
a one-time-use handle that represents the task that was suspended
and provides a means to resume it. The |suspended_task| class ensures
that every ticket is precisely accounted for.
When |suspended_task::resume_task()| is called on an instance with
a valid ticket, the resolver's |resolve_ticket()| method is invoked
passing the ticket's value along with *true* to resume the task. This
operation consumes the ticket so the |suspended_task| transitions to
an empty state. The ticket and resolver cannot be used again by
this |suspended_task| instance.
Similarly, when |suspended_task::reset()| is called on an instance with
a valid ticket or when the task goes out of scope on such an instance,
the resolver's |resolve_ticket()| method is invoked but this time passes
*false* to not resume the task. As before, the ticket is consumed.
Finally, when the |suspended_task| is copied, its ticket is duplicated
using |duplicate_ticket()| resulting in two tickets, both of which
must be individually resolved.
Resuming a task that has already been resumed has no effect.
Conversely, a task is considered "abandoned" if all of its tickets
have been resolved without it ever being resumed. See documentation
of |fpromise::promise| for more information.
The methods of this class are safe to call from any thread, including
threads that may not be managed by the task's executor.
Public Methods
ticket duplicate_ticket (ticket ticket)
Duplicates the provided ticket, returning a new ticket.
Note: The new ticket may have the same numeric value as the
original ticket but should be considered a distinct instance
that must be separately resolved.
void resolve_ticket (ticket ticket, bool resume_task)
Consumes the provided ticket, optionally resuming its associated task.
The provided ticket must not be used again.
Protected Methods
void ~resolver ()
Defined at line 1564 of file ../../sdk/lib/fit-promise/include/lib/fpromise/promise.h