E-MailRelay
Public Member Functions | List of all members
G::CallStack Class Reference

A linked list of CallFrame pointers. More...

#include <gcall.h>

Public Member Functions

 CallStack () noexcept
 Constructor.
 
 ~CallStack () noexcept
 Destructor. Calls invalidate() on all the frames in the stack. More...
 
CallFramepush (CallFrame *) noexcept
 Pushes a new innermost call frame onto the stack. More...
 
void pop (CallFrame *) noexcept
 Makes the given frame the innermost. More...
 
 CallStack (const CallStack &)=delete
 
 CallStack (CallStack &&)=delete
 
void operator= (const CallStack &)=delete
 
void operator= (CallStack &&)=delete
 

Detailed Description

A linked list of CallFrame pointers.

The motivation is the situation where an object, typically instantiated on the heap, emits some sort of synchronous signal, event, or callback and the receiving code somehow ends up deleting the originating object. If the emitting object might do more work before the stack unwinds then it can protect itself with a CallFrame check, with almost zero run-time cost:

class Emitter
{
CallStack m_stack ;
void do_stuff()
{
CallFrame this_( m_stack ) ;
emit( "doing stuff" ) ; // call client code - can do anything
if( this_.deleted() ) return ; // just in case
do_more_stuff() ;
}
} ;
CallStack() noexcept
Constructor.

Definition at line 57 of file gcall.h.

Constructor & Destructor Documentation

◆ ~CallStack()

G::CallStack::~CallStack ( )
inlinenoexcept

Destructor. Calls invalidate() on all the frames in the stack.

Definition at line 129 of file gcall.h.

Member Function Documentation

◆ pop()

void G::CallStack::pop ( CallFrame p)
inlinenoexcept

Makes the given frame the innermost.

Definition at line 144 of file gcall.h.

◆ push()

G::CallFrame * G::CallStack::push ( CallFrame p)
inlinenoexcept

Pushes a new innermost call frame onto the stack.

Definition at line 136 of file gcall.h.


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