High performance C++ framework for concurrent servers
Public Member Functions | List of all members
seastar::weakly_referencable< T > Class Template Reference

Detailed Description

template<typename T>
class seastar::weakly_referencable< T >

Allows obtaining a non-owning reference (weak_ptr) to the object.

A live weak_ptr object doesn't prevent the referenced object form being destroyed.

The underlying pointer held by weak_ptr is valid as long as the referenced object is alive. When the object dies, all weak_ptr objects associated with it are emptied.

A weak reference is obtained like this:

class X : public weakly_referencable<X> {};
auto x = std::make_unique<X>();
weak_ptr<X> ptr = x->weak_from_this();

The user of weak_ptr can check if it still holds a valid pointer like this:

if (ptr) ptr->do_something();

#include <seastar/core/weak_ptr.hh>

Public Member Functions

 weakly_referencable (weakly_referencable &&)=delete
 weakly_referencable (const weakly_referencable &)=delete
weak_ptr< T > weak_from_this () noexcept

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