Make default context thread_local (#286)

* Make default context thread_local

Signed-off-by: Ben Magistro <koncept1@gmail.com>
Co-authored-by: Vincent Richard <vincent@vincent-richard.net>
This commit is contained in:
bmagistro 2023-12-31 09:19:28 -05:00 committed by GitHub
parent 1a35bb6d71
commit 6e11c9c9f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -42,7 +42,7 @@ parsingContext::parsingContext(const parsingContext& ctx)
parsingContext& parsingContext::getDefaultContext() {
static parsingContext ctx;
static thread_local parsingContext ctx;
return ctx;
}

View File

@ -42,6 +42,12 @@ struct headerParseRecoveryMethod {
};
/** Holds configuration parameters used for parsing messages.
*
* Within vmime there are some functions that only utilize the default parsing
* context. If you need to manipulate the behavior of the parser for those
* functions, it is suggested to get the default context and make the
* appropriate set calls to adjust the behavior. You can also use this
* instance when making function calls the require a context be passed in.
*/
class VMIME_EXPORT parsingContext : public context {
@ -50,9 +56,10 @@ public:
parsingContext();
parsingContext(const parsingContext& ctx);
/** Returns the default context used for parsing messages.
/** Returns the default context used for parsing messages. The context
* is scoped as a thread local variable.
*
* @return a reference to the default parsing context
* @return a reference to the default parsing context for that thread
*/
static parsingContext& getDefaultContext();