Difference between revisions of "Effort/Make VCL Thread-Transparent"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Added DDE dependency.)
m (Typos fixed; style changed; Links added.)
Line 3: Line 3:
 
Status: in progress
 
Status: in progress
  
 +
== Making VCL Thread Transparent ==
 
VCL provides the OOo base widget set and windowing abstraction. It manages the event loop and dispatches the events. It also owns the display connection and manages various resources, e.g. fonts.
 
VCL provides the OOo base widget set and windowing abstraction. It manages the event loop and dispatches the events. It also owns the display connection and manages various resources, e.g. fonts.
  
; VCL hampers thread transparency in the following ways:
+
=== VCL hampers [[Uno/Term/Thread Transparent|Thread Transparency]] ===
:* It is [[Uno/Term/Thread Affine | Thread Affine]] under Windows - bascially letting shine through the Win32 thread affinity regarding window messages, window construction and window destruction.
+
VCL hampers [[Uno/Term/Thread Transparent|Thread Transparency]] in the following ways:
:* It provides the Solar MutEx, which needs to be acquired befor VCL can be called.  
+
* VCL is [[Uno/Term/Thread Affine | Thread Affine]] under Windows - bascially letting shine through the Win32 thread affinity regarding window messages, window construction and window destruction.
:* It completely releases the Solar MutEx in some sitations, without any hints at the API.
+
* VCL provides the Solar MutEx, which needs to be acquired befor VCL can be called.  
 +
* VCL completely releases the Solar MutEx in some sitations, without any hints at the API.
  
 
VCLs internals are not protected against concurrent access, except by the Solar MutEx, which needs to be locked from the outside. VCLs API only provides blocking or polling functions for accessing the event loop, which is especially bad as it does not offer a way, to avoid long acquired MutExes, while waiting for events, except by actively polling.
 
VCLs internals are not protected against concurrent access, except by the Solar MutEx, which needs to be locked from the outside. VCLs API only provides blocking or polling functions for accessing the event loop, which is especially bad as it does not offer a way, to avoid long acquired MutExes, while waiting for events, except by actively polling.
  
; To make VCL thread transparent, we propose, to:
+
=== Make VCL Thread Transparent ===
:* remove the Solar MutEx completely and declare VCL to be [[Uno/Term/Thread Unsafe | Thread Unsafe]], and to  
+
To make VCL thread transparent, we plan to
:* encapsulate calls to the [[Uno/Spec/Thread Affine | Thread Affine]] Win32 API, in a way, that this thread affinity is not visible from the outside.
+
* remove the Solar MutEx completely and to declare VCL to be [[Uno/Term/Thread Unsafe | Thread Unsafe]], and to  
The goal being that VCL behaves as an ordinary library, not showing any threading behavior at all.
+
* encapsulate calls to the [[Uno/Spec/Thread Affine | Thread Affine]] Win32 API, in a way, that this thread affinity is not visible from the outside ([[Uno/Term/Thread Transparent|Thread Transparency]]). The goal being that VCL behaves as an ordinary library, not showing any threading behavior at all.
  
To ensure short MutEx acquiration times, we propose to
+
=== Short MutEx Acquiration Times ===
* add a system handle providing API, so that we can poll/select on the handle in an outer event loop, and only need to enter VCL in case of an event.
+
To ensure short MutEx acquiration times, we plan to
 +
* add a system handle providing API, so that we can poll/select on the handle in an outer loop, and only need to enter VCL in case of pending events.
  
; Side effects:
+
=== Side Effets ===
:* Some Win32 based OOo components (DDE) expect their initialising thread eventually to enter the VCL event loop, to dispatch messages for objects created during this initialization. These implementations need to be adapted, to either delegate Win32 thread affine calls into VCLs new internal thread, or to create a thread for dispatching purposes by their own.
+
* Some Win32 based OOo components (e.g. DDE) rely on their initializing thread to eventually enter the VCL event loop, to dispatch messages for objects created during this initialization. These implementations need to be adapted, to either delegate Win32 thread affine calls into VCLs new internal thread, or to create a thread for dispatching purposes by their own.
:* With the removal of the Solar MutEx, VCL can not release a protecting MutEx anymore, which it currently does when executing a dialog. That means, that a protecting MutEx will stay acuired, basically disallowing other threads to enter VCL. This is needs to be addressed by [[Async Dialogs | making the office dialogs asynchron]].
+
* With the removal of the Solar MutEx, VCL can not release a protecting MutEx anymore, which it currently does when <code>executing</code> a dialog. That means, that a protecting MutEx will stay acquired during presence of the dialog, basically disallowing other threads to enter VCL. This is should be addressed by [[Async Dialogs | making the office dialogs asynchron]] and deprecating / removing the <code>execute</code> method.
  
; Time Frame: At least [[Removing the Solar MutEx]] and [[Encapsulating the inherited Win32 Thread Affinity]] are going to depend on [[Uno/Effort/Creating the Uno Threading Framework]], therefor VCL Thread Transparency will earliest be available after the UTF.
+
=== Time Frame ===
 +
At least [[Removing the Solar MutEx]] and [[Encapsulating the inherited Win32 Thread Affinity]] are going to depend on [[Uno/Effort/Creating the Uno Threading Framework]], therefor VCL Thread Transparency will earliest be available after the UTF.
  
 
; Dependencies
 
; Dependencies

Revision as of 09:00, 12 June 2006

[1], [2]

Status: in progress

Making VCL Thread Transparent

VCL provides the OOo base widget set and windowing abstraction. It manages the event loop and dispatches the events. It also owns the display connection and manages various resources, e.g. fonts.

VCL hampers Thread Transparency

VCL hampers Thread Transparency in the following ways:

  • VCL is Thread Affine under Windows - bascially letting shine through the Win32 thread affinity regarding window messages, window construction and window destruction.
  • VCL provides the Solar MutEx, which needs to be acquired befor VCL can be called.
  • VCL completely releases the Solar MutEx in some sitations, without any hints at the API.

VCLs internals are not protected against concurrent access, except by the Solar MutEx, which needs to be locked from the outside. VCLs API only provides blocking or polling functions for accessing the event loop, which is especially bad as it does not offer a way, to avoid long acquired MutExes, while waiting for events, except by actively polling.

Make VCL Thread Transparent

To make VCL thread transparent, we plan to

  • remove the Solar MutEx completely and to declare VCL to be Thread Unsafe, and to
  • encapsulate calls to the Thread Affine Win32 API, in a way, that this thread affinity is not visible from the outside (Thread Transparency). The goal being that VCL behaves as an ordinary library, not showing any threading behavior at all.

Short MutEx Acquiration Times

To ensure short MutEx acquiration times, we plan to

  • add a system handle providing API, so that we can poll/select on the handle in an outer loop, and only need to enter VCL in case of pending events.

Side Effets

  • Some Win32 based OOo components (e.g. DDE) rely on their initializing thread to eventually enter the VCL event loop, to dispatch messages for objects created during this initialization. These implementations need to be adapted, to either delegate Win32 thread affine calls into VCLs new internal thread, or to create a thread for dispatching purposes by their own.
  • With the removal of the Solar MutEx, VCL can not release a protecting MutEx anymore, which it currently does when executing a dialog. That means, that a protecting MutEx will stay acquired during presence of the dialog, basically disallowing other threads to enter VCL. This is should be addressed by making the office dialogs asynchron and deprecating / removing the execute method.

Time Frame

At least Removing the Solar MutEx and Encapsulating the inherited Win32 Thread Affinity are going to depend on Uno/Effort/Creating the Uno Threading Framework, therefor VCL Thread Transparency will earliest be available after the UTF.

Dependencies
Effort State
Make Dialogs Asynchronous in progress
Encapsulate the inherited Win32 Thread Affinity UTF2
Fix WIN32 DDE support (see above) open
Remove the Solar MutEx proof
Create a Handle API open
Personal tools