openframeworks/openFrameworks — pull request #1915 by bakercp (2013-03-04 18:17:57+00:00)
Title: A single line typedef, adding ofScopedLock (aka Poco::FastMutex::ScopedLock)

I have been using `Poco::FastMutex::ScopedLock` extensively lately and have noticed others doing the same. I propose adding this single line typedef to make lives easier and code cleaner.

For those who haven't experienced the wonders of scoped locks, it is a technique that helps ensure that mutexes get released/unlocked when they go out of scope, preventing deadlocks (i.e. the destruction of a scoped lock releases the mutex) resulting from forgetting to release / unlock your mutexes after use.

For instance:

```c++
void myApp::callAccessingSharedResources() {
myMutex.lock();
mySharedResource.modify();
myMutex.unlock(); // you can't forget this!
}
```
could be replaced with:

```c++
void myApp::callAccessingSharedResources() {
ofScopedLock lock(myMutex); // myMutex.lock() called upon construction of lock
mySharedResource.modify();
// as lock goes out of scope, its destructor is called
// inside of its destructor calls myMutex.unlock()
}
```