Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Asynchronous programming using standard C (http://www.velocityreviews.com/forums/t951728-asynchronous-programming-using-standard-c.html)

Chicken McNuggets 09-02-2012 10:28 PM

Asynchronous programming using standard C
 
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.

Nobody 09-03-2012 02:09 AM

Re: Asynchronous programming using standard C
 
On Sun, 02 Sep 2012 23:28:18 +0100, Chicken McNuggets wrote:

> 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.


Chicken McNuggets 09-03-2012 10:43 AM

Re: Asynchronous programming using standard C
 
On 03/09/2012 03:09, Nobody wrote:
> On Sun, 02 Sep 2012 23:28:18 +0100, Chicken McNuggets wrote:
>
>> 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.
>


Ah. Thanks for your response. That makes sense.


All times are GMT. The time now is 10:37 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.