|
synchronized statement in C++ |
axilmar
Member #1,204
April 2001
|
Here is a little article I wrote about how to do a synchronized statement in C++ that works in a similar way to Java. It's not very important, nor does it relate to games or Allegro, but I think it is cool . Enjoy. |
kazzmir
Member #1,786
December 2001
|
Thats kind of fun. I dont do a whole lot of multithreaded C++ work anymore but if I ever do I will surely use this. |
A J
Member #3,025
December 2002
|
thats a nice trick, pity it doesn't scale well. ___________________________ |
vpenquerch
Member #233
April 2000
|
Ah, yes, in my ideal world, etc, etc. But, hey, Rome wasn't built in a day. Nice one, Axilmar. |
HoHo
Member #4,534
April 2004
|
Besodes scaling it also seems to lack portability __________ |
A J
Member #3,025
December 2002
|
why would you start 2 of the same threads anyway ? ___________________________ |
gillius
Member #119
April 2000
|
Using RAII for mutexes should compile out to be the same code anyway. There's not a problem with it, in fact I use this idiom a lot. I don't understand the purpose of the flag attached to the mutex, though. Even if there was some overhead (I seriously expect there to be completely 0 overhead), I'd still use it since it is exception and return safe, and it is infinitely more convenient. I wouldn't go through the extras to make it look like Java. You can still do it in 1 line of code without the macro and it will look like normal C++. Gillius |
|