basic_string中的引用计数 [英] reference counting in basic_string

查看:96
本文介绍了basic_string中的引用计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在做一个从VC6.0到Visual Studio 2010的迁移项目.

在Visual Studio 6的xstring中,默认情况下, basic_string 不是线程安全的.为了使基本字符串的线程安全, Microsoft提出了解决该问题的建议.将_FROZEN定义为零而不是255.

在像VS2005,VS2010这样的更高版本中,此线程问题已解决?  还是有问题,我们需要在Visual Studio 2010中仍然使用_FROZEN定义吗?

谢谢

MS 开发人员


Miscrosoft Technologies Developer

解决方案

在2011年8月16日上午11:46, madhur写道:

在VisualStudio 6的xstring中,默认情况下 basic_string 不是线程安全的.

在诸如VS2005,VS2010之类的更高版本中,此线程问题已解决?

这个特别的,是的. basic_string实现不再使用写时复制或引用计数.因此,如果您复制一个字符串,则原始副本和副本完全是彼此独立的,并且可以由两个不同的线程自由处理.

从一个线程修改basic_string的一个实例的角度来看,basic_string仍然不是线程安全的,其他任何线程都不应读取或修改同一实例(但是可以在另一个实例上工作).


Hi All,

I am doing a migration project to Visual Studio 2010 from VC6.0.  

In xstring of VisualStudio 6, by deafult the basic_string is not thread safe.  To make basic strings thread safe,  Microsoft suggested a work around that  to define _FROZEN to Zero instead of 255.

In higher versions like VS2005, VS2010, this threading issue is solved ? OR   still we have the problem and we need to have the _FROZEN definition still with Visual Studio 2010?

Thanks

MS developer


Miscrosoft Technologies Developer

解决方案

On 8/16/2011 11:46 AM, madhur wrote:

In xstring of VisualStudio 6, by deafult the basic_string is*not thread safe*.

In higher versions like VS2005, VS2010, this threading issue is solved ?

This particular one, yes. basic_string implementation no longer uses copy-on-write or reference counts. So if you make a copy of a string, the original and the copy are completely independent of each other, and can be worked on freely by two different threads.

basic_string is still not thread-safe in the sense that, while one thread modifies an instance of basic_string, no other thread should read nor modify the same instance (but it's OK to work on a different instance).


这篇关于basic_string中的引用计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆