Happy New Year to the Poly/ML User Community!
I am trying to find a fix to a problem where we want to apply a function that sometimes takes far too long to execute. So I want to abort execution of the function after a specified time limit. I have a solution that seems to work by forking a worker thread to execute the function and store the result in a ref while the control thread goes into a loop that waits for 100ms and then either (1) returns the result from the ref if the worker thread is no longer active, (2) repeats if the thread is still active and we haven?t reaced the time limit or otherwise (3) kills the worker thread and returns a dummy value.
I am implementing this using Thread.ConditionVar.waitUntil and have two questions about that:
1) What does the bool returned by Thread.ConditionVar.waitUntil mean? That doesn?t seem to be documented.
2) In addition to the timeout, Thread.ConditionVar.waitUntil has a condition variable and a mutex as arguments. I am just creating these using Thread.ConditionVar.conditionVar and Thread.Mutex.mutex because I need some values to pass to Thread.ConditionVar.waitUntil. I am not doing any signalling or locking or unlocking. Is that going to cause any problems? (The condition variable and the mutex are local to the control thread function, so the worker thread function has no access to them.)
Regards,
Rob.