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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:39:32+00:00 2026-05-27T17:39:32+00:00

I have an application where I need to query a database to get/put information.

  • 0

I have an application where I need to query a database to get/put information. I can’t do it synchronously as it would block my entire process until the function returns.

Basically I have a few functions that run one or more queries at certain points.

fun
    stuff1
    stuff2
    stuff3

    query1
    stuff4

    query2
    stuff5
  • I could start the functions in separate threads, but then I would have to lock everything to prevent races (I think locking could be slow ?)

  • I could start the queries asynchronously and monitor them but then I would have to split my functions and use callbacks that would run when the qouery is over

I am interested in a general solution, but my platform is POSIX and the database is (unfortunately) mysql.

What would you do ? How would you handle this ?

Thank you for your time.

  • 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-27T17:39:33+00:00Added an answer on May 27, 2026 at 5:39 pm

    There are patterns that have been known and used for quite sometime and I believe they have not changed.

    1. Running independent functions: Use different threads
    2. Running independent functions and a then function dependent on all of them: Use different threads and joining them at the end – synchronise them. I do not know about POSIX but in .NET we have EventWaitHandle that can wait for multiple threads and notify when all finished.
    3. Running functions that each depends on another: run on a single background thread and chain the callbacks. Again .NET offers Task<T> chaining which makes reading and writing the code much simpler. jquery now offers promise which is the same thing.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a newbie question. If in my asp.net application I need to query
I have two application that need to talk to each other. App1 needs to
I have an application I need to analyze. I have the source code here.
I have this application that need to do some things in protected paths (like
I have an application where I need the user to upload a photo. After
I have a java application I need to pass some info to a C++
I have an application where I need to populate a textbox with a company
I have an application where I need to use 'Basic Authentication'; however, in order
I have an application where I need to INSERT an auto_increment value from a
Hokay so I have an application where I need some IPC... I'm thinking named

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.