These are constrains:
- I need use libxml2 SAX interface in multithreaded environment
- Code is statically linked
- I don't have control on threads, so I don't have a direct access to main thread from which
xmlParserInit()
should be called in accordance to documentation
I came up with the following idea
// SAXClient.cpp
const static bool PARSER_INITIALIZED = ()[] {
xmlParserInit();
return true;
}();
This code initializes the variable by the lambda called even prior to main() call in the main thread as it is required.
Do I miss some pitfall here?
Aucun commentaire:
Enregistrer un commentaire