0

Threaded script Execute and DWScript thread safe are not very clear about this situation:

A script is run in the context of a worker thread. While a script function is executing, called by the worker thread, it calls Delphi code which does some processing. This processing uses IPC to communicate with another thread (actually the mainthread) which will eventually call a procedure in the same script. This works nicely, at least from simple tests I conduced. But is this really allowed ?

Community
  • 1
  • 1
fpiette
  • 11,983
  • 1
  • 24
  • 46
  • Have you asked Eric? I think that's the best way to get a definitive answer. You'll probably be best doing so with some illustrative code. – David Heffernan Oct 21 '15 at 12:43
  • Eric's website state that support must be requested thru StackOverflow. That is what I do. – fpiette Oct 21 '15 at 13:12
  • Fair enough. I guess you need to wait for eric to turn up! – David Heffernan Oct 21 '15 at 13:14
  • Creating even a simplified version of my software will result in a large number of lines. Not sure it would help. The question itself is much simpler than implementation code. – fpiette Oct 21 '15 at 13:14
  • 2
    In my experience, when it comes to thread safety, the devil is always in the details. You say that there is no possible detail in your code that could affect the answer. That may be true. I wouldn't bet on it though. – David Heffernan Oct 21 '15 at 13:19
  • Maye be there are détails which makes a difference. Currently as far as I can test the code is perfectly working but - as you said - multithreading is not trivial, I prefer to ask if it should work or not. – fpiette Oct 21 '15 at 14:12
  • As long as you IPC call is blocking I can't see any problems. AFAIK there's no thread affinity in the script execution. If your IPC isn't blocking then you can end up with two threads executing the same script context and _that_ isn't allowed (and would probably bomb right away). – SpeedFreak Oct 21 '15 at 14:46
  • Yes, the threads are blocking. The first thread blocks until the second has done his work. Thanks. – fpiette Oct 22 '15 at 09:59

0 Answers0