I know of "select()" which works using file descriptors.
However I want similar functionality to "select()" but for a simple function that returns an int.
So suppose, there's "int calculate_magic()" function and I want to allow it to work for 2 seconds, if it takes longer than that I want to move on.
If "calculate_magic()" wrote its answer to a file descriptor I could use "select()" but how to do it for the case I mentioned?
I need something like this for a simple game implementation where the player is allowed a maximum time to make a decision about their next move.
I
was hoping I can get something without having to deal with threads, etc.