Beast Logo

PrevUpHomeNext

handler_ptr

A smart pointer container with associated completion handler.

template<
    class T,
    class Handler>
class handler_ptr
Types

Name

Description

element_type

The type of element this object stores.

handler_type

The type of handler this object stores.

Member Functions

Name

Description

get

Returns a pointer to the owned object.

handler

Returns a reference to the handler.

handler_ptr

Move constructor.

Copy constructor.

Construct a new handler_ptr.

invoke

Invoke the handler in the owned object.

operator bool

Returns true if *this owns an object.

operator*

Return a reference to the owned object.

operator->

Return a pointer to the owned object.

operator=

Copy assignment (disallowed).

release_handler

Release ownership of the handler.

~handler_ptr

Destructs the owned object if no more handler_ptr link to it.

This is a smart pointer that retains shared ownership of an object through a pointer. Memory is managed using the allocation and deallocation functions associated with a completion handler, which is also stored in the object. The managed object is destroyed and its memory deallocated when one of the following happens:

Objects of this type are used in the implementation of composed operations. Typically the composed operation's shared state is managed by the handler_ptr and an allocator associated with the final handler is used to create the managed object.

Remarks

The reference count is stored using a 16 bit unsigned integer. Making more than 2^16 copies of one object results in undefined behavior.

T

The type of the owned object.

Handler

The type of the completion handler.

Requirements

Header: beast/core/handler_ptr.hpp

Convenience header: beast/core.hpp


PrevUpHomeNext