I quite like the .NET inspired variant described above - where the asynchronous code is something like
****************** void connect_callback(State cookie, void *ctx) { connection = end_connect(cookie); }
{ ... begin_connect(stuff, bits, callback, NULL); ... } ******************
and the synchronous code is
{ ... connection = connect(stuff, bits); ... }
where the connect() function is simply
connect(Stuff stuff, Bits bits) { cookie = begin_connect(stuff, bits, NULL, NULL); return end_connect(cookie); }
I quite like the .NET inspired variant described above - where the asynchronous code is something like
****************** callback( State cookie, void *ctx) cookie) ;
void connect_
{
connection = end_connect(
}
{ connect( stuff, bits, callback, NULL);
...
begin_
...
}
******************
and the synchronous code is
{
...
connection = connect(stuff, bits);
...
}
where the connect() function is simply
connect(Stuff stuff, Bits bits) stuff, bits, NULL, NULL); cookie) ;
{
cookie = begin_connect(
return end_connect(
}