[shared_ptr] InterlockedIncrement rocks!

Hi Peter, I just took your implementation (http://www.pdimov.com/cpp/shared_count_x86_exp2.hpp) for shared_ptr and use it now in win32gui (upcoming v1.4.2). Using Interlocked* for win32 totally rocks! From my tests - Interlocked* are very fast. They're about twice as slow as a raw increment (or my tests are wrong;)). From what I see - I think you can certainly merge them into boost::shared_ptr. Maybe users can select the old version or this Interlocked* version with a certain macro - like BOOST_SHARED_PTR_USE_INTERLOCKED. Also, why not including windows.h directly, like this: #define WIN32_LEAN_AND_MEAN #include <windows.h> <side-note> From my tests it seems your version as is now fails to link for gcc (unresolved external _InterlockedIncrement/_InterlockedDecrement). However, if #including <windows.h> and use InterlockedIncrement/Decrement - they work. </side-note> Best, John -- John Torjo -- john@torjo.com Contributing editor, C/C++ Users Journal -- "Win32 GUI Generics" -- generics & GUI do mix, after all -- http://www.torjo.com/win32gui/ -- v1.4 - save_dlg - true binding of your data to UI controls! + easily add validation rules (win32gui/examples/smart_dlg)

John Torjo wrote:
Also, why not including windows.h directly, like this: #define WIN32_LEAN_AND_MEAN #include <windows.h>
Its nice to avoid this if at all possible. windows.h dumps a whole lot of stuff into the global namespaces that cause all sorts of problems. Ideally a Boost header would only include things that were well-behaved and contained in appropriate namespaces. Aaron W. LaFramboise
participants (2)
-
Aaron W. LaFramboise
-
John Torjo