Skip to main content
gamedev.net
🔒 Locked

Data Sharing in OOP program?

Started by dragon376 0 replies 200+ views
Original Post
dragon376
dragon376
How can I share data from a class accross threads. Usually all the data is syncronized together because it is together in a structure. How is done when the data is in an object. Thanks
Fruny
Fruny
Structures do NOT ensure synchronization. Neither do classes.
All threads share the same memory. You can use member functions
of a class to get the values of the member variables. But do
remember to put a mutex in the right place. Or, in windows, a
critical section. Or several. And beware the deadlocks.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.