Uno/Binary/Spec/Thread Affinity Bridge

From Apache OpenOffice Wiki
< Uno‎ | Binary
Revision as of 16:06, 12 April 2006 by Kr (Talk | contribs)

Jump to: navigation, search

author: Kr
version: 7810
state: draft
created: 01/17/2006
type: specification

Binary UNO

Thread Affine Environment

Description
The Thread Affine Environment protects thread affine objects from being called by the 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 any objects create an affinity to.
Feature
A purpose environment protecting thread affine objects:
- enter: Associates the current thread with the environment
- leave: An case no objects are mapped it disassociates the current thread with the environment, in case objects are mapped and this is the last leave, it blocks until no objects are mapped anymore.
- callInto: Calls the desired method from the associated thread.
- callOut: Calls the desired method from the outer thread, if there is no outer thread yet, the associated thread is used.
Rationale
Some APIs have thread affinities in respect to particular handles they return. For exmaple, on Win32 the window create, 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 affinie 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
Compatibility Issues
None.
Dependencies
  • EnvStack
Personal tools