是否有任何对 C++ 很重要的常见设计模式或常见习惯用法? win32多线程编程?
一个例子是: RAII - 资源获取是与关键部分一起使用的初始化
还有其他重要的、流行的并且您经常使用的吗?
One example could be: RAII - Resource Acquisition is Initialization used with critical sections
Any others that are important, popular and you often use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此链接提到了很多。 命令模式可以方便地将请求分派给线程。 领导者/追随者似乎也是一个有趣的模式。
This link mentions quite a few. The Command pattern comes in handy for dispatching requests to threads. Leader/Followers seems to be an interesting pattern as well.
您也可以尝试以下方法:模式和习惯用法
You can try this also: patterns and idioms
对于我当前的产品和高性能桌面应用程序,我使用消息传递,不共享并发过去曾写过。 根据我的经验,最好避免共享数据同步。 您可以使用NamedPipes、窗口消息或套接字在线程之间进行通信。
如果您确实决定尝试同步对共享数据的访问,看看这个主题。
I use message passing, share nothing concurrency both for my current product and for high performance desktop applications I have written in the past. In my experience, its better to avoid shared data synchronization. You can use NamedPipes, window messages or sockets to communicate between threads.
If you do decide to try and syncronize access to shared data, take a look at this topic.