Hello GNU libmicrohttpd developers,
I want to implement the following using this excellent library:
The application maintains a fixed-size thread pool. Each thread executes asynchronous non-blocking code. Request processing should NEVER block.
For example (the following explanation describes a single thread's behavior, but this should apply to all threads):
   1. An HTTP request arrives, and MHD invokes the handler callback.
   2. Inside this callback, I need to query a database.
   3. A synchronous DB query would be slow and inefficient—the application should process other requests while waiting for the DB response.
   4. Instead, I want to make a non-blocking DB request with a callback: "Dear DB client library, when you receive a response from the DB, invoke this callback (containing further application logic). For now, send the SQL query and return immediately."
What I expect from MHD:
   - MHD should not wait inside the HTTP handler for a response.
   - MHD should remember that this request is pending until the DB callback (or subsequent logic) triggers an MHD response callback with the finalized data.
Could you please demonstrate how to implement this with MHD? The documentation lacks such an example and doesn’t clearly explain how to achieve this workflow. It would be fantastic if you could add this example to the documentation.
Thank you.
 
-- 
wbr,
Leonid
 

Reply via email to