Use Interlocked* functions

Mike McCormack mike at codeweavers.com
Mon Jan 10 16:42:22 CST 2005


Mike Hearn wrote:

> To be quite honest I'm not convinced this janitorial task is a good idea.
> It makes the code look at first glance like it's thread safe when it
> actually isn't. A better janitorial task would simply be "Make
> free-threaded COM objects thread safe" except that making code thread safe
> can actually be quite a lot of work, it's not just copy/paste.

Well, it's true that some objects don't need to be thread safe, however 
it's not recorded anywhere in the Wine source which object need to be 
thread safe and which don't.

The most important reason in my mind to do this is so that people 
implementing objects in the future copy code that uses the Interlocked* 
functions.  There's no overhead to using those functions... no penalty 
if we use them in code that doesn't need to be thread safe, so we should 
just use them everywhere.

The janitorial task doesn't say "Make ole32 objects thread safe" because 
that's alot more work.  It is one small step in the process of making 
objects thread safe... an introduction if you like.  Hopefully it helps 
some newcomers to Wine understand thread safety and OLE objects a 
little.  Maybe then oneday they'll can that the code isn't thread safe, 
and undertake to fix some of it, which is a much bigger and harder task.

Until then this is something easy for people to do to help out.

Mike



More information about the wine-devel mailing list