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 8188609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:58:19+00:00 2026-06-07T02:58:19+00:00

I need advice in design and c++ implementation (I am a java guy, new

  • 0

I need advice in design and c++ implementation (I am a java guy, new to c++).

I have list of processes.
One thread add/remove process to the list and second thread once in 10ms runs and collects all processes (and removes them from the list) that have timed out. Each process has a creation timestamp when it was added to the list. If 3 sec have passed and the process is still in the list (not removed by the first thread) it is removed from the list by the cleaner process.

This has to be with low overhead.

So I have processListContainer with 3 methods:
add, remove , clean

need to sync between the add/removeById and the clean.
This can be done by clever thinking such as creating a new list when cleaning, and handle multiple lists.

The list size is around 100K and thousands added in sec

  • 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-06-07T02:58:21+00:00Added an answer on June 7, 2026 at 2:58 am

    You can organize your list of processes into a list of sublists. Each sublist is a collection of processes that would expire within the same 5ms interval. This would allow your cleaner thread to clear out an entire sublist when it is deciding to remove stale processes, instead of iterating through individual processes.

    The list initially contains an empty sublist.

    The clean operation is a loop with the exit condition being either the head sublist is empty or the head sublist is not expirable. If the head sublist has expired, it cleans out the list. If the list has more than 1 sublist, it removes the resulting empty sublist. The loop repeats.

    So, add would check to see if the process belongs to the last sublist. If so, it adds itself to that sublist. If not, it creates a new sublist, and adds itself to it, and adds the sublist to the list.

    The remove element removes the provided element from the sublist. If the sublist becomes empty, and there is more than one sublist in the list, it removes the empty sublist.

    In this scheme, add should not need to lock, since it only manipulates the tail, or an unexpirable sublist. clean and remove both need locks since they may both manipulate the head of the list.

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

Sidebar

Related Questions

I need some advice for a design which I have to implement in application.
I need some advice about the design on my app. I have several screens
I'm kind of new to iOS development and need some advice. I have a
I need an advice w.r.t. one of the design approach we are considering. We
I need your advice regarding my design and if you have a better idea
I need an advice about USB programming in linux. i have to design a
I have a new project and just need some advice on how to do
I'd need advice on following situation with Oracle/PostgreSQL: I have a db table with
I really need advice on how to do the following. I have tried several
I think I have this working but I need advice. I'd like to know

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.