What model do you like better: Asynchronous state-machine based on
callbacks, or single-threaded model backed by user-space threads? Its a
difference between something like this:
class IO_Callbacks {
virtual void On_Send(...) = 0;
virtual void On_Receive(...) = 0;
// [...];
};
class My_Connection : public IO_Callbacks {
void On_Send(...) {
// [handle the event];
}
void On_Recv(...) {
// [handle the event];
}
};
or:
void My_Connection(...) {
for (;;) {
if (! IO_Receive(...)) {
break;
}
if (! IO_Send(...)) {
break;
}
}
}
I have to admit that the latter is easier to reason about. I can't make up
my mind! Dammit!
;^(...