|
-
February 1st, 2005, 05:48 PM
#9
Re: Thread synchronization
 Originally Posted by MikeAThon
But beyond PODs, synchronization is essential. If you define your own data structure, then it is essential to protect even read-only access to an object of that structure with a synchronization object.
Why would it? Why would it matter whether the operation is atomic or not given the fact that the data isn't going to change. Thus, even if one thread gets interrupted while reading the value, it is still guaranteed that the value is till the same when it got again CPU time and read further.
 Originally Posted by MikeAThon
And in the end, isn't it easier simply to use synchronization objects always, as a precaution? (For example, a precaution that in some future release, your formerly POD variable is changed into a multi-part structure)
As I said...it has nothing to do with PODs in the first place...besides that, synchronization is something that you buy at a high cost...in CPU cycles...thus, if you have something that is guaranteed to be read-only...you can increase the performance of your application by simply skipping the (unnecessary) synchronization...
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
|