Various APIs require calls to initialization and finalization methods. Most recently I've come across this while using the Python C++ API, where all API calls must be between calls to Py_Initialize
and Py_FinalizeEx
. My current solution is to put such calls at the beginning and end of the main method. This does not seem ideal, as it separates the actual usage of the API from it's resource management. That is, the software components which make API calls rely on the main method to acquire and destroy the resources.
Is there a pattern that is usually applied in such a scenario?
Aucun commentaire:
Enregistrer un commentaire