I know when I work with sockets or file I can set it for non-block and use epoll for example to make a async server, but my doubt is when I don't have a file descriptor like happens with sockets, for example, imagine a query in a database, how can I make a query without block my thread, and pass a callback like happens on Node.js
for example:
queryDB("select something from mytable", my_callback);
and queryDB return immediately.
My doubt is how do I make this function queryDB with this behavior.