Passing handle to C++ classes across a C API boundary
问题 I am writing a library in C++, but want it to have a C API, which should also be thread safe. One thing that the API needs to do is to pass back and forth handles (e.g. a structure containing a reference or pointer) of objects created within the library. These objects need to be destroyed at some point, so any handles to such an object that were still in existence would them become invalid. EDIT: We cannot assume that each handle is only used within a single client thread. In particular I