class LeaseHelper

Defined at line 103 of file ../../sdk/lib/driver/power/cpp/power-support.h

|LeaseHelper| wraps the collection of channels that represents a power

element. When used with |CreateLeaseHelper| the caller just supplies

the level of the required element(s) and dependency token(s). The caller

does not need to create an element it manages to get the dependencies

to the level it needs, instead it can use the |LeaseHelper| returned from

|CreateLeaseHelper|.

The |LeaseHelper| runs an element internally and exposes a convenient

interface, |AcquireLease| which leases the wrapped element at the "on"

state and consequentally drives the dependencies to their desired state.

Public Methods

void LeaseHelper (const std::string & lease_name, fidl::ClientEnd<fuchsia_power_broker::ElementControl> element_control, fidl::ClientEnd<fuchsia_power_broker::Lessor> lessor, fidl::ServerEnd<fuchsia_power_broker::ElementRunner> element_runner_server, async_dispatcher_t * dispatcher, fit::function<void ()> error_callback, inspect::Node * parent)

Creates a |LeaseHelper| running on the supplied |dispatcher|. The lease

is **not** active when the constructor returns, use |AcquireLease| for.

this. Blocking the dispatcher while waiting for the callback from

|AcquireLease| will result in a deadlock.

|error_callback| is called if |LeaseHelper| encounters an error running

its wrapped power element. If the error handler is invokes, the

|LeaseHelper| should be dropped and a new one created.

Defined at line 113 of file ../../sdk/lib/driver/power/cpp/power-support.h

void AcquireLease (fit::function<void (fidl::Result<fuchsia_power_broker::Lessor::Lease> &)> callback)

Trigger the lease acquisition. The lease is **created**, but not active,

when |callback| is invoked. The lease is active when

`fuchsia.power.broker/LeaseControl` channel given to |callback| reports

`fuchsia.power.broker/LeaseStatus::Satisfied` from

`fuchsia.power.broker/LeaseControl.WatchStatus()`.

Release the lease by closing the `LeaseControl` channel. |AcquireLease|

can be called more than once and creates a lease for each call.

Defined at line 615 of file ../../sdk/lib/driver/power/cpp/power-support.cc