!! Thread safe mutex for C++ implementation of proofreaders !!

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

!! Thread safe mutex for C++ implementation of proofreaders !!

thomas.lange


Hi all,

One word of warning:
Some time ago it turned out that a simple code line like this
    vos::OGuard aGuard( GetMyMutex() );
is NOT thread-safe on all platforms!

To get a threadsafe Mutex (which you are need for proofreaders!) do the
following:
  #include <rtl/instance.hxx>
  //!! multi-thread safe mutex for all platforms !!
  struct MySafeMutex : public rtl::Static< osl::Mutex, MySafeMutex >
  {
  };

and then, later in the code, use it like this:
  osl::MutexGuard  aGuard( MySafeMutex ::get() );


Regards,
Thomas



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]