-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed syntatical errors, moved token class definition to context.h an…
…d added the contextvars_context.h file
- Loading branch information
Showing
3 changed files
with
80 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#ifndef CONTEXT_VARS_CONTEXT_H_ | ||
#define CONTEXT_VARS_CONTEXT_H_ | ||
|
||
#include "context.h" | ||
#include <string> | ||
|
||
|
||
/* An implementation of the RuntimeContext interface which wraps | ||
* ContextVar under the hood */ | ||
class ContextVarsRuntimeContext: public RuntimeContext{ | ||
|
||
std::string _CONTEXT_KEY = "current_context"; | ||
|
||
|
||
/* ContextVarsRuntimeContext: Default constructor to set the | ||
* current context to the thread local context | ||
* | ||
* Args: None | ||
*/ | ||
ContextVarsRuntimeContext(); | ||
|
||
|
||
/* attach: Sets the current 'Context' object. Returns a token | ||
* that can be used to reset to the previous Context. | ||
* | ||
* Args: | ||
* context : the context to set. | ||
*/ | ||
Context attach(Context context); | ||
|
||
|
||
/* get_current: Return the current context. | ||
* | ||
* Args: None | ||
*/ | ||
Context get_current(); | ||
|
||
/* detach: Resets the context to a previous value. | ||
* | ||
* Args: | ||
* token: A reference to a previous context | ||
*/ | ||
Token detach(Token token); | ||
|
||
}; | ||
|
||
|
||
|
||
#endif //CONTEXT_VARS_CONTEXT_H_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters