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
 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
 
CallStackoperator= (const CallStack &)=delete
 
CallStackoperator= (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 ) ;
do_some_stuff() ;
emit( "doing stuff" ) ; // call client code - can do anything
if( this_.deleted() ) return ; // just in case
do_more_stuff() ;
}
} ;

Definition at line 58 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 124 of file gcall.h.

Member Function Documentation

◆ pop()

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

Makes the given frame the innermost.

Definition at line 139 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 131 of file gcall.h.


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