|
Boost : |
Subject: [boost] boost.atomic library works on Linux but not on Windows -- please help
From: Anqing Xu (anqingxu_at_[hidden])
Date: 2010-07-07 17:16:09
Hi,
In search of a std:atomic<T> implementation, I decided
to give boost.atomic library a try. My initial investigation found it worked
fine under linux. However it does not
work on Windows.
Here is a little test program to demonstrate:
#include <iostream>
#include <boost/atomic.hpp>
#include <boost/lockfree/detail/tagged_ptr.hpp>
#include <boost/lockfree/detail/freelist.hpp>
int main()
{
boost::lockfree::caching_freelist<int>
pool(3);
int* pInt1 = pool.allocate();
*pInt1 = 1;
int* pInt2 = pool.allocate();
*pInt2 = 2;
int* pInt3 = pool.allocate();
*pInt3 = 3;
pool.deallocate(pInt1);
pool.deallocate(pInt2);
pool.deallocate(pInt3);
int* pInt4 = pool.allocate();
int* pInt5 = pool.allocate();
int* pInt6 = pool.allocate();
}
The test uses boost.lockfree library, which you can download
from http://tim.klingt.org/git?p=boost_lockfree.git
If you set a break point, say in fallback.hpp, you will see
that on Windows it falls back to spinlock.
Can somebody please suggest how to fix this?
I suspect the issue has something to do with intptr_t type.
I looked into the code but quickly started to have
headache. Atomic library uses template
metaprogramming and is not easy to understand.
-Anqing
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk