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

  • Home
  • SEARCH
  • 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 5931323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:40:41+00:00 2026-05-22T14:40:41+00:00

Is it possible, after calling a boost::thread running some instructions, to come back to

  • 0

Is it possible, after calling a boost::thread running some instructions, to come back to main thread ?

My code is based around proactor pattern, however a certain function may take some time, so in order not to block the whole program, I’m creating a thread running this function.
When this function is over, I need to call another function, but it has to be run on main thread.
I have a connection pool, that is not thread safe, and I really would like to avoid mutex.

Is there a stable way to run a function on the main thread (call on another thread) ?

Just like in ObjectiveC performSelectorOnMaintThread

  • 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-22T14:40:42+00:00Added an answer on May 22, 2026 at 2:40 pm

    I think you might want to look into boost asio strands. They will let you specify which thread (strand) to do some wok on, and it will automatically get queued on that strand.

    Note that a strand is actually more like a fiber (meaning: if there are more strands than actual threads, the strands will get multiplexed onto the available threads).

    IIRC this won’t however give you chance to explicitely specify the main thread1. However, more often than not this is not the actual requirement: what strands let you do easily is to make sure that operations in a strand run on the same logical thread, i.e. no concurrency is ever possible within a strand.

    Trivia: Boost Asio io_service.run() is an example of a message pump

    Here is the samples page for Boost Asio: http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/examples.html

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

Sidebar

Related Questions

Is it possible somehow to close StreamReader after calling ReadToEnd method in construction like
Possible Duplicate: how to hide a div after some time period? i need to
After peeking around the internet it looks like it is possible to interop between
After calling exec, is it possible to print a message, because I tried and
in MVC 3 is it possible to rollback the database after calling DbContext.SaveChanges() ?
With Crockford's JSLINT , after calling JSLINT() to parse some JavaScript source, it provides
When calling my PreferenceActivity from a screen, and after pressing the Back button, the
Greetings all, I am calling Type.GetProperties(), but after running Dotfuscator, it is returning zero
I'm using Visual Studio 2010 RC. Would it be possible that after doing my
Is it possible to leave a ContextMenuStrip open after a selection/check of certain items?

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.