简体   繁体   English

重新编写此智能指针

[英]Re-writing this smart pointer

Im transferring some code from ACE to Poco. 我将一些代码从ACE转移到Poco。 I'm new to multithreaded design so it is confusing me just a little! 我是多线程设计的新手,所以让我有些困惑!

typedef Arc::AutoPtr<ResultSet, ACE_Thread_Mutex> QueryResult;

Im not able to just re-write it like this, as Poco::AutoPtr only accepts one argument as a class template 我无法像这样重新编写它,因为Poco :: AutoPtr仅接受一个参数作为类模板

typedef Poco::AutoPtr<ResultSet, Poco::Mutex> QueryResult;

How should i write it? 我应该怎么写?

I'm not sure what Arc::AutoPtr is, because I couldn't find anything like that in the ACE documentation. 我不确定Arc::AutoPtr是什么,因为我在ACE文档中找不到类似的内容。 However if it's the same as ACE_Refcounted_Auto_Ptr then the corresponding typedef for Poco would probably be typedef Poco::SharedPtr<ResultSet> QueryResult; 但是,如果它与ACE_Refcounted_Auto_Ptr相同,则Poco的对应typedef可能就是typedef Poco::SharedPtr<ResultSet> QueryResult; . But it's not clear from the docs whether the SharedPtr in Poco implements a thread safe reference counting, so you have to be careful of that. 但是从文档中尚不清楚Poco中的SharedPtr是否实现了线程安全引用计数,因此您必须注意这一点。

Poco::AutoPtr is actually an intrusive smart pointer which requires support from the pointed type (similar to boost::intrusive_ptr ). Poco::AutoPtr实际上是一个侵入式智能指针,它需要指向类型的支持(类似于boost::intrusive_ptr )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM