[vtkusers] vtkMutexLock is recursive?

Sebastien Valette sebastien.valette at creatis.insa-lyon.fr
Tue Jan 31 12:00:47 EST 2006


Hi all,
I am working on multithreaded processing, and I found out that the 
vtkMutexLock is actually a recursive lock, meaning that
when calling twice the vtkMutexLock::Lock() method from the same thread 
does not block the program execution. Here is a short sample code:

****************** begin code ********************

#include "vtkMutexLock.h"
#include "vtkCriticalSection.h"

int main( int argc, char* argv[] )
{
    vtkMutexLock *MyLock=vtkMutexLock::New();
    MyLock->Lock();
    MyLock->Lock();
    cout<<"Passed"<<endl;

    vtkCriticalSection *MyLock2=vtkCriticalSection::New();
    MyLock2->Lock();
    MyLock2->Lock();
    cout<<"Passed 2"<<endl;
    return 0;
}
******************** End Code *********************
This program will execute without any lockup.

I think that this "feature" should be mentioned in the documentation.

-- 
http://www.creatis.insa-lyon.fr/~valette/




More information about the vtkusers mailing list