Index  Source Files  Annotated Class List  Alphabetical Class List  Class Hierarchy  Graphical Class Hierarchy 

FIX::CallStack Class Reference

Keeps track of callstacks for multiple threads. More...

#include <CallStack.h>

Collaboration diagram for FIX::CallStack:
Collaboration graph
[legend]

List of all members.

Classes

class  Context
 A single CallStack context (thread of execution). More...
class  Ignore
 Use this in a code block that should ignore CallStack traces. More...
struct  Method
 Represents a method in the CallStack. More...

Public Member Functions

 CallStack (const std::string &name, const std::string &file, int line)
 ~CallStack ()

Static Public Member Functions

static void output ()
static void ignore (bool)
static void caught (std::exception &e)
static void caught ()
static void terminate ()

Static Private Member Functions

static ContextgetContext ()
static ContextgetErrorContext ()

Static Private Attributes

static std::map< thread_id,
Context
s_stack
static std::map< thread_id,
Context
s_error
static Mutex s_mutex

Detailed Description

Keeps track of callstacks for multiple threads.

Definition at line 39 of file CallStack.h.


Constructor & Destructor Documentation

FIX::CallStack::CallStack ( const std::string &  name,
const std::string &  file,
int  line 
)

Definition at line 37 of file CallStack.cpp.

References getContext(), getErrorContext(), FIX::CallStack::Context::ignore, s_mutex, and terminate().

00038   {
00039     Locker locker(s_mutex);
00040 
00041     #if TERMINATE_IN_STD
00042       std::set_terminate(FIX::CallStack::terminate);
00043     #else
00044       set_terminate(FIX::CallStack::terminate);
00045     #endif
00046 
00047     Context& c = getContext();
00048     if( !c.ignore )
00049     {
00050       c.push(Method(name, file, line));
00051       getErrorContext() = c;
00052     }
00053   }

FIX::CallStack::~CallStack (  ) 

Definition at line 55 of file CallStack.cpp.

References getContext(), FIX::CallStack::Context::ignore, and s_mutex.

00056   {
00057     Locker locker(s_mutex);
00058     Context& c = getContext();
00059     if( !c.ignore )
00060       c.pop();
00061   }


Member Function Documentation

void FIX::CallStack::caught (  )  [static]

Definition at line 94 of file CallStack.cpp.

References FIX::CallStack::Context::caught(), getErrorContext(), FIX::CallStack::Context::ignore, and s_mutex.

00095   {
00096     Locker locker(s_mutex);
00097     Context& c = getErrorContext();
00098     if( c.ignore ) return;
00099     c.caught();
00100   }

void FIX::CallStack::caught ( std::exception &  e  )  [static]

Definition at line 86 of file CallStack.cpp.

References FIX::CallStack::Context::caught(), getErrorContext(), FIX::CallStack::Context::ignore, and s_mutex.

00087   {
00088     Locker locker(s_mutex);
00089     Context& c = getErrorContext();
00090     if( c.ignore ) return;
00091     c.caught(e);
00092   }

CallStack::Context & FIX::CallStack::getContext (  )  [static, private]

Definition at line 102 of file CallStack.cpp.

References s_mutex, s_stack, and FIX::thread_self().

Referenced by CallStack(), ignore(), and ~CallStack().

00103   {
00104     Locker locker(s_mutex);
00105     return s_stack[thread_self()];
00106   }

CallStack::Context & FIX::CallStack::getErrorContext (  )  [static, private]

Definition at line 108 of file CallStack.cpp.

References s_error, s_mutex, and FIX::thread_self().

Referenced by CallStack(), and caught().

00109   {
00110     Locker locker(s_mutex);
00111     return s_error[thread_self()];
00112   }

void FIX::CallStack::ignore ( bool  value  )  [static]

Definition at line 80 of file CallStack.cpp.

References getContext(), FIX::CallStack::Context::ignore, and s_mutex.

Referenced by FIX::CallStack::Ignore::Ignore(), and FIX::CallStack::Ignore::~Ignore().

00081   {
00082     Locker locker(s_mutex);
00083     getContext().ignore = value;
00084   }

void FIX::CallStack::output (  )  [static]

Definition at line 63 of file CallStack.cpp.

References FIX::CallStack::Context::exception, s_error, and s_mutex.

Referenced by terminate().

00064   {
00065     Locker locker(s_mutex);
00066     std::map<thread_id, CallStack::Context>::iterator i;
00067     for( i = s_error.begin(); i != s_error.end(); ++i )
00068     {
00069       Context& c = i->second;
00070       if(c.size())
00071         std::cerr << "thread(" << i->first << "):" << c.exception << std::endl;
00072       while(c.size())
00073       {
00074         std::cerr << "  at " << c.top() << std::endl;
00075         c.pop();
00076       }
00077     }
00078   }

void FIX::CallStack::terminate (  )  [static]

Definition at line 114 of file CallStack.cpp.

References output(), and s_mutex.

Referenced by CallStack().

00115   {
00116     Locker locker(s_mutex);
00117     CallStack::output();
00118     abort();
00119   }


Member Data Documentation

std::map< thread_id, CallStack::Context > FIX::CallStack::s_error [static, private]

Definition at line 109 of file CallStack.h.

Referenced by getErrorContext(), and output().

Mutex FIX::CallStack::s_mutex [static, private]
std::map< thread_id, CallStack::Context > FIX::CallStack::s_stack [static, private]

Definition at line 108 of file CallStack.h.

Referenced by getContext().


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

Generated on Mon Apr 5 20:59:58 2010 for QuickFIX by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2001