CodeContext.h File Reference
#include "base/InstanceId.h"
#include "base/RefCount.h"
#include <iosfwd>
Include dependency graph for CodeContext.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CodeContext
 
class  CodeContextGuard
 

Functions

std::ostream & operator<< (std::ostream &os, const CodeContext &ctx)
 by default, only small context gist is printed More...
 
std::ostream & CurrentCodeContextBrief (std::ostream &os)
 
std::ostream & CurrentCodeContextDetail (std::ostream &os)
 
template<typename Fun >
void CallBack (const CodeContext::Pointer &callbackContext, Fun &&callback)
 
template<typename Fun >
void CallService (const CodeContext::Pointer &serviceContext, Fun &&service)
 
template<typename Fun >
void CallContextCreator (Fun &&creator)
 

Function Documentation

◆ CallBack()

template<typename Fun >
void CallBack ( const CodeContext::Pointer callbackContext,
Fun &&  callback 
)
inline

Executes service callback in callbackContext. If an exception occurs, the callback context is preserved, so that the exception is associated with the callback that triggered them (rather than with the service).

Service code running in its own service context should use this function.

Definition at line 81 of file CodeContext.h.

References callback, CodeContext::Current(), and CodeContext::Reset().

Referenced by HappyOrderEnforcer::checkpoint(), IpcIoFile::checkTimeouts(), IpcIoFile::handleResponse(), and idnsCallbackAllCallersWithNewAnswer().

◆ CallContextCreator()

template<typename Fun >
void CallContextCreator ( Fun &&  creator)
inline

Executes context creator in the service context. If an exception occurs, the creator context is preserved, so that the exception is associated with the creator that triggered them (rather than with the service).

Service code running in its own context should use this function to create new code contexts. TODO: Use or, if this pattern is not repeated, remove.

Definition at line 113 of file CodeContext.h.

References CodeContext::Current(), and CodeContext::Reset().

◆ CallService()

template<typename Fun >
void CallService ( const CodeContext::Pointer serviceContext,
Fun &&  service 
)
inline

Executes service in serviceContext but due to automatic caller context restoration, service exceptions are associated with the caller that suffered from (and/or caused) them (rather than with the service itself).

Service code running in caller's context should use this function to escape into service context (e.g., for submitting caller-agnostic requests).

Definition at line 98 of file CodeContext.h.

Referenced by IpcIoFile::push(), and IpcIoFile::scheduleTimeoutCheck().

◆ CurrentCodeContextBrief()

std::ostream& CurrentCodeContextBrief ( std::ostream &  os)

Referenced by operator<<().

◆ CurrentCodeContextDetail()

std::ostream& CurrentCodeContextDetail ( std::ostream &  os)

Definition at line 94 of file CodeContext.cc.

References CodeContext::Current().

Referenced by Debug::Finish(), and operator<<().

◆ operator<<()

std::ostream& operator<< ( std::ostream &  os,
const CodeContext ctx 
)
inline

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors