Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7705775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:56:43+00:00 2026-05-31T23:56:43+00:00

The documentation is not very clear on how unsafe concurrent_queue::unsafe_size() is. The doxygen comment

  • 0

The documentation is not very clear on how unsafe concurrent_queue::unsafe_size() is.

The doxygen comment in the file tbb/internal/concurrent_queue.h mentions:

Get size of queue; result may be invalid if queue is modified
concurrently

What I am interested in knowing is will it return a valid size at some point in the past, or may it return garbage ? (Provided that several threads are both reading and writing).

I am not interested in the exact value, but more on a “load” indication. I want to prevent my queue to explode in capacity when the consumer threads have a problem. I’d use concurrent_bounded_queue which as the name suggest has a capacity control, but I would lose the lock-free property.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:56:44+00:00Added an answer on May 31, 2026 at 11:56 pm

    You really should treat it as garbage because it is marked unsafe. I think it may actually return questionable numbers because if memory serves its really a difference between pushes and pops. However even if it were ‘safe’ it would still only return a number that was valid in the past, that’s one of the joys of wait free programming.
    If you really need to reason about the counts store an atomic count in the class that holds the queue.

    Is there a reason you are not using one of the tasking primitives in tbb instead of building your own?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The documentation here is not very clear: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing&s[]=editurl#saverow Do I have to manually make
How should Java's drawImage() be used? I do not find the JDK documentation very
I am not clear from the documentation - when I indicate a cell width
It's not clear in the documentation how you can access the likes of a
The documentation does not say much besides: Private: Changes made to the resulting buffer
A method that overrides another method does not inherit documentation of the method it
The documentation for -hash says it must not change while a mutable object is
AVFoundation.framework is not where the documentation says it should be. I have iPhone SDK
The Java documentation says: it is not possible for two invocations of synchronized methods
math.h is not really a documentation. Is there something else that will describe these

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.