Difference between revisions of "Uno/Spec/Threading-Model"

From Apache OpenOffice Wiki
< Uno‎ | Spec
Jump to: navigation, search
m
Line 9: Line 9:
  
 
; Feature
 
; Feature
: A UNO Runtime provides support for implementing ''thread safe'', ''thread unsafe'' or ''thread affine'' code.
+
: The UNO Runtime provides support for implementing
 
+
:* [[Uno/Spec/Thread Safe | Thread Safe]], or  
: The UNO Threading Model allows code to leverage external locking, respectively to leverage thread specificy. Code can either be specified to be
+
:* [[Uno/Spec/Thread Unsafe | Thread Unsafe]], or
:* thread safe, or to be
+
:* [[Uno/Spec/Thread Affine | Thread Affine]]
:* thread unsafe, or to be
+
: Code.
:* thread affine.
+
 
+
;; : Thread Safe Code
+
:: Thread safe code takes care of all threading issues, including locking critical sections etc. Code doing blocking I/O needs to be thread safe, so that system calls can be interrupted. Thread safe code may also be used to allow high concurrency, while avoiding the runtime overhead of external locking.
+
 
+
;; : Thread Unsafe Code
+
:: Thread unsafe code must not care of any threading issues, except thread affinity. Thread unsafe code must be implemented [[Thread Transparent]]. On the desgined level of granularity methods are guaranteed to not be called concurrently. The calling thread may vary over time.
+
: The Unsafe Threading Model should become the standard model of implementation. Ensuring all code to be in this Model and utilizing only one thread should give optimal performance without any threading overhead.
+
 
+
;; : The Thread Affine Code
+
:: Thread affine code must not care of any threading issues, ''including'' thread affinity. Thread affine code must be implemented [[Thread Transparent]]. On the designed level of granularity methods are guaranteed to not be called concurrelty. Thread calling thread ''does not'' vary over time.
+
: Declaring code to be thread affine is e.g. very usable for programming Windows thread affine APIs as OLE or WIN32.
+
  
 +
: The threading type of any code can be specified appropriately. The [[Uno/Spec/Thread Unsafe | Thread Unsafe]] type is the default type for any implementation.
  
 
; Rationale:
 
; Rationale:

Revision as of 08:32, 18 April 2006

author: Kr
version: 8163
state: draft
created: 12/12/2005
type: specification


UNO Threading Model

Feature
The UNO Runtime provides support for implementing
Code.
The threading type of any code can be specified appropriately. The Thread Unsafe type is the default type for any implementation.
Rationale
API
Purpose UNO Environments: The different threading models are accessible as standard UNO environments (CPP: uno/environment.h). Environment specifications (e.g. "gcc3", "java") are extended by "purpose" specifiers (e.g. ":mutex", ":thread"), purpose specifiers may be chained (e.g. ":mutex:debug:test").
The predefined purposes to objects according to their threading type are
  • ":mutex" - for thread unsafe code,
  • ":thread" - for thread affine code, and
  • "" - for thread safe code, to ensure compatibility with previous UNO versions.
Stacked Environments: The current (purpose) environment does not only vary with the implementation language (e.g. Java or C++), but also with the executed codes declared threading type. Therefor an API for accessing the current environment is provided.
Cascaded Mappings: Purpose environments may be passed to the Runtime for getting cascaded mappings ("gcc3" => "java:mutex:debug").
Implementation Environments: Client code as well as service code may be declared once, to either be thread safe, thread affine or thread unsafe.
Dependencies
Thread Environment
Mutex Environment
Cascaded Mapping
Compatibility Issues
None.
Personal tools