proxygen
folly::DestructorCheck Class Reference

#include <DestructorCheck.h>

Inheritance diagram for folly::DestructorCheck:
wangle::ClientBootstrap< DefaultPipeline > proxygen::HPACKQueue proxygen::HTTPMessageFilter proxygen::QPACKDecoder wangle::ClientBootstrap< Pipeline > CustomPipelineMakerTestClient proxygen::MockHTTPMessageFilter

Classes

class  ForwardLink
 
class  Safety
 

Public Member Functions

virtual ~DestructorCheck ()
 

Private Attributes

ForwardLink rootGuard_
 

Detailed Description

DestructorCheck is a helper class that helps to detect if a tracked object was deleted. This is useful for objects that request callbacks from other components.

Classes needing this functionality should:

Callback context can be extended with an instance of DestructorCheck::Safety object initialized with a reference to the object dereferenced from the callback. Once the callback is invoked, it can use this safety object to check if the object was not deallocated yet before dereferencing it.

DestructorCheck does not perform any locking. It is intended to be used only from a single thread.

Example:

class AsyncFoo : public DestructorCheck { public: ~AsyncFoo(); // awesome async code with circuitous deletion paths void async1(); void async2(); };

righteousFunc(AsyncFoo& f) { DestructorCheck::Safety safety(f);

f.async1(); // might have deleted f, oh noes if (!safety.destroyed()) { // phew, still there f.async2(); } }

Definition at line 57 of file DestructorCheck.h.

Constructor & Destructor Documentation

virtual folly::DestructorCheck::~DestructorCheck ( )
inlinevirtual

Member Data Documentation

ForwardLink folly::DestructorCheck::rootGuard_
private

Definition at line 133 of file DestructorCheck.h.

Referenced by folly::DestructorCheck::Safety::Safety(), and ~DestructorCheck().


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