Asynchronous programming using standard C

  • Thread starter Chicken McNuggets
  • Start date
C

Chicken McNuggets

I'm interested in asynchronous programming but am having a few problems
understanding the underlying implementation.

I assume that asynchronous programming is generally done by calling a
function (which includes a call back function pointer in its arguments)
which starts a thread and then immediately returns. Once the thread has
completed the task it then calls the call back function to return the
data to the caller.

Is this the basic idea of asynchronous programming or have I got it
completely wrong?

Thankfully threading is now on-topic in this group thanks to C11.

Thank you for any help.
 
N

Nobody

I assume that asynchronous programming is generally done by calling a
function (which includes a call back function pointer in its arguments)
which starts a thread and then immediately returns. Once the thread has
completed the task it then calls the call back function to return the
data to the caller.

Is this the basic idea of asynchronous programming or have I got it
completely wrong?

That is one specific example of an asynchronous system.

Other examples might have the thread invoke the callback whenever
something interesting happens, not just on completion, or might avoid the
callback and have the initiator poll for updates. Or there may not be a
separate thread, just an event-processing loop which invokes callbacks as
events arrive (the callbacks are synchronous with respect to the
event-dispatching function but asynchronous with respect to the code which
installed them or which triggered the event).

"Asynchronous" generally just means that code is structured to accept
information as it becomes available rather than blocking until the
information is provided.
 
C

Chicken McNuggets

That is one specific example of an asynchronous system.

Other examples might have the thread invoke the callback whenever
something interesting happens, not just on completion, or might avoid the
callback and have the initiator poll for updates. Or there may not be a
separate thread, just an event-processing loop which invokes callbacks as
events arrive (the callbacks are synchronous with respect to the
event-dispatching function but asynchronous with respect to the code which
installed them or which triggered the event).

"Asynchronous" generally just means that code is structured to accept
information as it becomes available rather than blocking until the
information is provided.

Ah. Thanks for your response. That makes sense.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top