Modify

Opened 4 years ago

Closed 4 years ago

#8135 closed Bugs (fixed)

[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 (0)

Change History (1)

comment:1 Changed 4 years ago by timblechmann

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

(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

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain timblechmann.
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.