[Interest] QNetworkAccessManager in a command line, non-eventloop application

Scott Aron Bloom scott.bloom at onshorecs.com
Fri Jan 18 18:08:46 CET 2013


On sexta-feira, 18 de janeiro de 2013 01.49.35, Scott Aron Bloom wrote:
> I don't want to block

Yet you're describing exactly a blocking situation:

> I would like a background thread and have the request run in there, 
> using the QThreads event loop.

The background thread runs an event loop, sure, but what is the main thread doing in the meantime? Since it doesn't have an event loop, it cannot receive events. The only synchronisation mechanisms left are QWaitCondition and QSemaphore, which means the main thread must block waiting for the background thread to finish the operation.

You really don't have a choice besides those two. Network access is not instantaneous. You must either use the event loop or you need to block.

Choose one.
-----------------------------
Blocking at the end, is ok... Blocking while the application is running is not.  Yes, I want my cake and to eat is as well :)

I essentially want to kick off the request at the beginning of the run, then let the request run its course in the backround.

If the main application (no event loop at all, non-event driven, nonQt for the most part), finishes first (rare occasion) I can block on the background thread ending.  However most times, the single http request will have finished long before

Scott



More information about the Interest mailing list