Opened 10 years ago

Closed 10 years ago

#7403 closed Bugs (fixed)

lockfree support in MSVC 2012

Reported by: Zouzou <internet@…> Owned by: timblechmann
Milestone: To Be Determined Component: lockfree
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:

Description

Hi,

MSVC 2012 has atomics; it therefore allows boost.lockfree to be used with it.

Using boost.atomic on MSVC is not an option because it falls back to interlocked functions (not lock-free).

Here is a simple patch for lockfree's atomic.hpp showing the necessary changes:

  • don't define BOOST_LOCKFREE_NO_HDR_ATOMIC in order to use <atomic>, not <boost/atomic.hpp>.
  • remove the (cplusplus < 201103L) check because cplusplus is defined to 199711 on MSVC 2012...

There is an additional change in freelist.hpp: include <boost/cstdint.hpp> (it was being included by <boost/atomic.hpp>).

With these changes lock-free lists seem to be working fine! :) (I verified that is_lock_free() does return true.)

Feel free to adjust the patch of course; this is just to show what is required to make boost.lockfree truly lock-free on MSVC 2012. I'm available for any further questions.

Thanks for adding atomic & lockfree. :) Zouzou

Attachments (1)

msvclockfree.patch (1.2 KB ) - added by Zouzou <internet@…> 10 years ago.
Patch

Download all attachments as: .zip

Change History (2)

by Zouzou <internet@…>, 10 years ago

Attachment: msvclockfree.patch added

Patch

comment:1 by timblechmann, 10 years ago

Resolution: fixed
Status: newclosed

applied to trunk, thanks for the patch!

Note: See TracTickets for help on using tickets.