Difference between revisions of "Thread safety in Visual Prolog"

From wiki.visual-prolog.com

(category)
(threadsafe facts)
Line 1: Line 1:
Thread safe:
Thread safe:


* Access to fact variables
* Access facts
* Access to single facts
* Access to determ facts


'''Not''' thread safe:
'''Not''' thread safe:


* Nondeterm facts
* GUI
* GUI
* Streams
* Streams
* odbcConnection/odbcStatement
* odbcConnection/odbcStatement


=== Nondeterm facts ===
=== Facts ===


Read access is thread safe, but only a single thread should update a nondeterm fact.  Reading can be done while update takes place.
See [[Threadsafe facts]].


=== GUI ===
=== GUI ===

Revision as of 16:18, 19 February 2019

Thread safe:

  • Access facts

Not thread safe:

  • GUI
  • Streams
  • odbcConnection/odbcStatement

Facts

See Threadsafe facts.

GUI

Windows GUI is not thread safe, only the thread that runs the message pump of a window should accees that window. In Visual Prolog all windows (except modal dialogs) belong to the thread that have executed the vpi::init call.

Synchronization back to the GUI thread can be done using window::postAction, because the posted action will be executed by the GUI thread.

Modal dialogs run their own message pump and they are therefore owned by the thread that displays them.

Streams

Streams are in general not thread safe, but specific streams can be.

From Visual Prolog 7.4 the thread on messageControls are thread safe. In a GUI application stdio will thus be thread safe while it is redirected to a messageControl/messageForm, but if it is redirected to some other stream it will "inherit" the thread safety from that stream.

ODBC

An odbcConnection/odbcStatement is not thread safe, but different odbcConnection's/odbcStatement's can be accessed in parallel.