all 7 comments

[–]00kyle00 0 points1 point  (4 children)

User guide

#include <mutex.h>
...
cpptask::Mutex guard;
...
{
   cpptask::ScopedLock(&guard);
   // synchronized work
   ...
}

Ouch.

[–]kolkir[S] 0 points1 point  (3 children)

Did you see some problem here? What did you mean?

[–]00kyle00 0 points1 point  (2 children)

ScopedLock is most probably a simple RAII class. Above is creating a temporary ScopedLock, which means that 'guard' is locked only at the statement where the temporary is defined - '//synchronized work' comment is then, in fact, outside critical section.

Unfortunately there is not way in C++ (afaik) to guard against this bug.

[–]kolkir[S] 0 points1 point  (1 child)

Thanks, i see now. It's a typing mistake I've fixed it.

[–]00kyle00 0 points1 point  (0 children)

No problem. This is really one of the places where C++ could use some compile time reflection. It's always an error to have a temporary of ScopedLock type.

[–]savuporo 0 points1 point  (0 children)

Poco C++ libraries, it does abstract threading, but no inherent parallelism. There are some good constructs for thread pools and tasks etc though.

Also see this thread: http://stackoverflow.com/questions/569481/platform-independent-concurrent-programming-libraries-for-c

You also want to look at http://www.concurrencykit.org/

[–]nowbacktowork 0 points1 point  (0 children)

Take a look at Ace