On 08/08/2013 07:07, Dmitry Popoinikov wrote:
???????, 6 ??????? 2013, 13:55 +01:00 ?? David Matthews <David.Matthews at prolingua.co.uk>:
On 04/08/2013 22:31, Dmitry Popoinikov wrote:
Hi Dmitry, I can't see there would be any problem with running a Poly/ML program for a long time. Provided your application only requires a constant data size there's no reason why the heap should grow beyond a steady state. There will be periodic garbage collections of course.
I've now added code to the SVN version so that a thread created within foreign code can call an ML callback. I've done some simple tests of it but you may want to test it more exhaustively.
Regards, David
Hi David, My program works well now. Thank you very much!
Hi Dmitry, I discovered a problem with the code that I added and I have had to remove some of it. In the callback code there is a check to see if the thread has ever been in ML code before and if not Poly creates some data structures for it which includes an ML stack. The difficulty is in knowing when to remove this data. Threads created by Poly always call an "exit" function and that removes the data for those threads but it's not possible to use that for threads created by foreign code. I added some code to the "main" thread to try to detect when a thread has exited but that caused crashes. It seems that, unlike with Windows, there is no safe way to discover when a thread created with pthreads has exited. The simplest possibility would be to remove the data and the ML stack as soon as the callback returns, if that callback created the data. If your thread is making many calls to the callback that could be expensive. Would that be a problem for your code?
Regards, David