...
首页> 外文期刊>C - C++ Users Journal >Creating Dynamic Singletons & the Loki Library
【24h】

Creating Dynamic Singletons & the Loki Library

机译:创建动态单例和Loki库

获取原文
获取原文并翻译 | 示例

摘要

My C++ program is using a third-party database library. It uses one object that represents the state of the database. The database object can be dynamically deleted to release all of its resources and it needs to be automatically deleted if it still exists at program termination. "So how am 1 going to solve this problem?" I ask myself. The "one object" requirement screams for a Singleton solution. But the ability to dynamically destroy a Singleton isn't handled by most Singleton implementations. After the Singleton has been manually destroyed, it needs to automatically resurrect itself the next time it's used in the program. Also, if the Singleton exists when the program terminates, it needs to destroy itself to release its resources.
机译:我的C ++程序正在使用第三方数据库。它使用一个代表数据库状态的对象。可以动态删除数据库对象以释放其所有资源,如果在程序终止时它仍然存在,则需要将其自动删除。 “那么1将如何解决这个问题呢?”我问我自己。对于Singleton解决方案,“一个对象”的要求大声疾呼。但是,大多数Singleton实现无法处理动态销毁Singleton的功能。手动销毁Singleton之后,下次需要在程序中使用它时,它需要自动恢复自身。另外,如果在程序终止时存在Singleton,则需要销毁自身以释放其资源。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号