Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::view::DispatchLease Class Reference

RAII gate held across any call into overridable View code. More...

#include <view_lifecycle.hpp>

Public Types

enum class  Drain { at_exit , deferred }
 When the outermost lease on a tree is released, is it safe to destroy what was retired during the pass? More...

Public Member Functions

 DispatchLease (View &view, Drain drain=Drain::at_exit) noexcept
 ~DispatchLease ()
 DispatchLease (const DispatchLease &)=delete
DispatchLease & operator= (const DispatchLease &)=delete
 DispatchLease (DispatchLease &&)=delete
DispatchLease & operator= (DispatchLease &&)=delete
View * root () const noexcept
 The root whose gate this lease raised.

Detailed Description

RAII gate held across any call into overridable View code.

Construction walks to the tree root and raises that root's lease depth plus the leased view's own dispatch depth; destruction lowers both and, when the root's depth returns to zero, destroys everything retired during the pass.

Take one at the call site inside the member that invokes the hook:

{
DispatchLease lease(*child);
child->on_attached(); // may remove/destroy `child`
} // retirement drains here (outermost)
// `child` is still alive above; re-validate identity before using it.
DispatchLease(View &view, Drain drain=Drain::at_exit) noexcept

A lease keeps the view's storage alive; it does not keep it attached. A hook may still detach or replace the view, so re-validate identity (address and import_binding_instance_id(), or a ViewCapture) after every hook returns.

Member Enumeration Documentation

◆ Drain

When the outermost lease on a tree is released, is it safe to destroy what was retired during the pass?

Enumerator
at_exit 

Yes.

The hook has already returned, so nothing retired during it can still be executing. This is the case for every View-internal call site, where the lease brackets the hook rather than living inside it.

deferred 

No.

The lease itself lives inside the callback it guards — a bridge callback takes its scope as the first statement of the std::function body, so the lease destructor still runs inside std::function::operator(). Destroying a retired view there can free the very closure that is executing. Retirement instead carries over and drains when the next outermost lease is taken.

Constructor & Destructor Documentation

◆ DispatchLease() [1/3]

pulp::view::DispatchLease::DispatchLease ( View & view,
Drain drain = Drain::at_exit )
explicitnoexcept

◆ ~DispatchLease()

pulp::view::DispatchLease::~DispatchLease ( )

◆ DispatchLease() [2/3]

pulp::view::DispatchLease::DispatchLease ( const DispatchLease & )
delete

◆ DispatchLease() [3/3]

pulp::view::DispatchLease::DispatchLease ( DispatchLease && )
delete

Member Function Documentation

◆ operator=() [1/2]

DispatchLease & pulp::view::DispatchLease::operator= ( const DispatchLease & )
delete

◆ operator=() [2/2]

DispatchLease & pulp::view::DispatchLease::operator= ( DispatchLease && )
delete

◆ root()

View * pulp::view::DispatchLease::root ( ) const
inlinenoexcept

The root whose gate this lease raised.

Stored at construction so a lease released after its view was detached still lowers the depth it raised.


The documentation for this class was generated from the following file: