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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:13:37+00:00 2026-06-15T13:13:37+00:00

I have a C++ multi-threaded application which run tasks in separate threads. Each task

  • 0

I have a C++ multi-threaded application which run tasks in separate threads. Each task have an object which handles and stores it’s output. Each task create different business logic objects and probably another threads or threadpools.

What I want to do is somehow provide an easy way for any of business logic objects which are run by task to access each task’s output without manually passing “output” object to each business logic object.

What i see is to create output singleton factory and store task_id in TLS. But the problem is when business logic create a new thread or thread pool and those thread would not have task_id in TLS. In this way i would need to have an access to parent’s thread TLS.

The other way is to simply grab all output since task’s start. There would be output from different task in that time, but at least, better than nothing…

I’m looking for any suggestions or ideas of clean and pretty way of solving my problem. Thanks.

upd: yeah, it is not singletone, I agree. I just want to be able to access this object like this:

output << "message";

And that’s it. No worry of passing pointers to output object between business logic classes. I need to have a global output object per task.

  • 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-15T13:13:38+00:00Added an answer on June 15, 2026 at 1:13 pm

    From an application point of view, they are not singletons, so why treating the objects like singletons?

    I would make a new instance of the output storer and pass the (smart?) pointer to the new thread. The main function may put the pointer in the TLS, thus making the instance global per thread (I don’t think that this is a wise design deision, but it is asked). When making a new (sub-?)thread, the pointer can again be passed. So according to me, no singletons or factories are needed.

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

Sidebar

Related Questions

I have a multi-threaded application in C# which tries to write to a TextBox
I have a multi threaded python application communicating with a separate service trough UDP.
I have a multi-threaded application which parses some text and it needs to use
I'm trying to solve a classic problem - I have a multi-threaded application which
Here's the scenario: I have a multi threaded java web application which is running
I have a multi-threaded application which needs to display certain dates to the user.
We have created a multi-threaded application which process/parse big files (few hundred MB's) simultaneously.
i have a multi-threaded application which wants to send a sequence of data to
I have a multi-threaded application which scales well to begin with, but running on
I have a multi threaded application where I allocate buffers with data, which then

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.