Difference between revisions of "Uno/Spec/Thread Affinity Bridge"

From Apache OpenOffice Wiki
< Uno‎ | Spec
Jump to: navigation, search
m
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
version: {{REVISIONID}} <br>
+
Type: specification  State: stable
state:  draft          <br>
+
type:    specification  <br>
+
  
== Thread Affinity Bridge ==
+
A [[../Purpose Bridge|purpose bridge]] protecting [[Uno/Term/Thread Affine|thread-affine]] objects.
  
; Description
+
==Feature==
: The Thread Affine Bridge protects [[Uno/Spec/Thread Affine|Thread Affine]] objects from being called by wrong threads. It does this by providing a dedicated thread, into which it delegates the calls prior to invocation. This dedicated thread is therefor the thread objects create any affinity to.
+
The [[Uno/Term/Thread Affine|thread-affinity]] bridge ensures that encapsulated objects are always called by the same thread, thus compensating any [[Uno/Term/Thread Affine|thread-affinity]]. The affinity bridge also ensures, that calls into or through it do not show any [[Uno/Term/Thread Aware|thread awareness]].
  
; Feature:
+
Only one thread at a time can enter an affinity environment, an affinity environment is entered, if any thread has one of the methods provided by the <code>Enterable</code> API on the stack.
: A [[Uno/Spec/Protocol Bridge|Protocol Bridge]] protecting [[Uno/Spec/Thread Affine|Thread Affine]] objects:
+
: - <code>enter</code>: Associates the current thread with the [[Uno/Spec/Environment|Environment]]
+
: - <code>leave</code>: In case no objects are mapped it disassociates the current thread from the [[Uno/spec/Environment|Environment]], in case objects are mapped and this is the last <code>leave</code>, it blocks until no object is mapped anymore.
+
:
+
: - <code>callInto</code>: Calls the desired method in the associated thread.
+
: - <code>callOut </code>: Calls the desired method in the outer thread, if there is no outer thread yet, the associated thread is used.
+
  
; Rationale
+
==Rationale==
: Some APIs have [[Uno/Spec/Thread Affine|thread affinities]] in respect to particular handles they return. For example, on Win32 the window-destroy and -message functions require to be called by the same thread which actually created the window. This thread affinity is inherited when developing APIs on top of these thread affine APIs.
+
Some APIs have [[Uno/Term/Thread Affine|thread-affinities]] in respect to particular handles they return. For example, on Win32 the window-destroy and -message functions require to be called by the same thread which actually created the window. This [[Uno/Term/Thread Affine|thread-affinity]] is inherited when developing APIs on top of these [[Uno/Term/Thread Affine|thread-affine]] APIs.
: In general, thread affine APIs are hard to program, especially in generic frameworks where it is not knowable before hand how long a thread lives and on whichs objects it calls.
+
  
; API
+
In general, [[Uno/Term/Thread Affine|thread-affine]] APIs are hard to program, especially in generic frameworks where it is not knowable before hand how long a thread lives and on whichs objects it calls.
: Bridge named <code>"affine"</code>.
+
  
; Compatibility Issues: None.
+
==API==
 +
A [[../Purpose Bridge|purpose bridge]] named <code>":affine"</code>.
  
; Dependencies:
+
==Dependencies==
:* EnvStack
+
* [[../Environment Stack]]
 +
* [[../Purpose Environment]]
  
 +
 +
[[Category:Draft]]
 +
[[Category:Spec]]
 +
[[Category:Uno]]
 
[[Category:Uno:Spec]]
 
[[Category:Uno:Spec]]
 +
[[Category:Multi-Threading]]

Latest revision as of 07:21, 19 June 2007

Type: specification State: stable

A purpose bridge protecting thread-affine objects.

Feature

The thread-affinity bridge ensures that encapsulated objects are always called by the same thread, thus compensating any thread-affinity. The affinity bridge also ensures, that calls into or through it do not show any thread awareness.

Only one thread at a time can enter an affinity environment, an affinity environment is entered, if any thread has one of the methods provided by the Enterable API on the stack.

Rationale

Some APIs have thread-affinities in respect to particular handles they return. For example, on Win32 the window-destroy and -message functions require to be called by the same thread which actually created the window. This thread-affinity is inherited when developing APIs on top of these thread-affine APIs.

In general, thread-affine APIs are hard to program, especially in generic frameworks where it is not knowable before hand how long a thread lives and on whichs objects it calls.

API

A purpose bridge named ":affine".

Dependencies

Personal tools