阅读背景:

当不再有引用时,如何从缓存中删除智能指针?

来源:互联网 

I've been trying to use smart pointers to upgrade an existing app, and I'm trying to overcome a puzzle. In my app I have a cache of objects, for example lets call them books. Now this cache of books are requested by ID and if they're in the cache they are returned, if not the object is requested from an external system (slow operation) and added to the cache. Once in the cache many windows can be opened in the app, each of these windows can take a reference to the book. In the previous version of the app the programmer had to maintain AddRef and Release, when every window using the Book object was closed, the final Release (on the cache manager) would remove the object from the cache and delete the object. I've been trying to use smart pointers to upgra




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: