• Advertisement

Archived

This topic is now archived and is closed to further replies.

Does C++ provide synchronize method?

This topic is 5853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does C++ provide synchronized method like that: [Java] class Test{ synchronized void Something(){.....} } If yes, how to do that? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Mm.....I have two threads. Those are GameController and NetworkController. Also, i have a SharedMemory Handler.
The GameController handles the game flow. e.g. hero move in map...
NetworkController handles the send and receive data from/to server....
The SharedMemory Handler is a common area that store all other online player''s heros data those are in the same map...

I want to make one and only one controller can access the SharedMemory''s data at a time. So i remember java provided synchronized method for me to do that. How can i do that at C++?


Share this post


Link to post
Share on other sites
Threads are not functions of C/C++--they're only available through libraries, usually interfacing the OS. How are you starting your thread? If you tell us what library you're using for threads, we can probably tell you what synchronization primitives the library offers.

For example, if you're using win32, you've got InitializeCriticalSection, CreateMutex, CreateSemaphore, etc.

[edited by - Stoffel on April 17, 2002 1:09:34 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Stoffel
Threads are not functions of C/C++--they're only available through libraries, usually interfacing the OS.



I read They plan to add them in they next version of the standard library though.

Edit: forgot the capital T

[edited by - Fruny on April 17, 2002 1:30:40 PM]

Share this post


Link to post
Share on other sites

  • Advertisement