In c/c++ server design, event call always the painful part. How to register callback functions:
- Use global or static method?
- Use event class and vritual method call?
- How to handle the memory between caller and callee?
- How to pass context, use pointer? use handle?
So many questions need to be taken care, but, maybe under the script world, life will be more easy…..
Lua thoughts:
- Use coroutines, when do an async call, we stop this coroutine, when callback, we resume the coroutine, so each context is there, we do not need pass anything, only the coroutine handler.
- Functional languange easy to pass or generate callback function, so handler some very simple callback event, are very convenient.