Modify

Ticket #8135 (closed Bugs: fixed)

Opened 4 years ago

Last modified 4 years ago

[lockfree] compile time capacity difference behavior

Reported by: Akira Takahashi <faithandbrave@…> Owned by: timblechmann
Milestone: To Be Determined Component: lockfree
Version: Boost 1.53.0 Severity: Problem
Keywords: Cc:

Description

 http://lists.boost.org/boost-users/2013/02/77649.php

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?

Attachments

Change History

comment:1 Changed 4 years ago by timblechmann

  • Status changed from new to closed
  • Resolution set to fixed

(In [83079]) lockfree: queue - allocate one element more than required

the queue internally uses a dummy node, which is not user-visible. therefore we should allocate one element more than needed

fixes #8135

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.