Boost logo

Boost Users :

Subject: [Boost-users] [lockfree] compile-time capacity vs. run-time capacity
From: Akira Takahashi (faithandbrave_at_[hidden])
Date: 2013-02-15 00:51:33


Hi,
I confused with boost::lockfree::queue behavior.

Fist, run-time capacity:

#include <iostream>
#include <boost/lockfree/queue.hpp>

int main()
{
    boost::lockfree::queue<int, boost::lockfree::fixed_sized<true>> que(3);

    std::cout << std::boolalpha;

    std::cout << que.push(1) << std::endl; // true
    std::cout << que.push(2) << std::endl; // true
    std::cout << que.push(3) << std::endl; // true
    std::cout << que.push(4) << std::endl; // false
}

I think this behavior is correct.

But, compile-time capacity:

#include <iostream>
#include <boost/lockfree/queue.hpp>

int main()
{
    boost::lockfree::queue<int, boost::lockfree::capacity<3>> que;

    std::cout << std::boolalpha;

    std::cout << que.push(1) << std::endl; // true
    std::cout << que.push(2) << std::endl; // true
    std::cout << que.push(3) << std::endl; // false : why?
    std::cout << que.push(4) << std::endl; // false
}

Is this bug or specification?

Thanks,
Akira

>>========================
Akira Takahashi
mailto:faithandbrave_at_[hidden]
site: https://sites.google.com/site/faithandbrave/about/en



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net