|
-
April 3rd, 2013, 10:21 AM
#10
Re: Can local variable be passed as parameter into a new thread?
 Originally Posted by Paul McKenzie
However, I don't have the source code to CString at the moment, so I'll ask:
If CString is reference counted, is the reference counting thread-safe? In other words, if that temporary copy used in ProcessContentThreadFunction() is destroyed simultaneously with the destruction of the CString in some_function, is this guaranteed to be OK?
That's a good question. In the implementation of CString on VS2005 and VS2008, I see that the reference count is in-/decremented with interlocked* functions. I think that's enough to make the CoW implementation thread-safe. I.e. if no single CString object is accessed from multiple threads unsynchronized, I don't see how it can fail.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|