Changes between Version 45 and Version 46 of DjangoSpecifications/Core/Threading
- Timestamp:
- Apr 26, 2008, 3:50:37 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DjangoSpecifications/Core/Threading
v45 v46 16 16 The main pattern of global variable usage in Django is ''use `var` if initialized, otherwise initialize''. This is generally not thread-safe. 17 17 18 "Not thread-safe" has two broad subcategories :19 * inefficiencies due to initialization calls meant to occur only once occurring more than once ( the general `if not foo: initialize foo`,including `memoize` decorator),18 "Not thread-safe" has two broad subcategories in this case: 19 * inefficiencies due to initialization calls meant to occur only once occurring more than once (including `memoize` decorator), 20 20 * errors due to incomplete initialization. 21 21 … … 25 25 * locking would needlessly penalize single-threaded execution. 26 26 27 Thus, lock-free algorithms should be always preferred and the inefficient case tolerated -- unless the inefficiency is highly probable and results in overhead that is considerably greater than with locking .27 Thus, lock-free algorithms should be always preferred and the inefficient case tolerated -- unless the inefficiency is highly probable and results in overhead that is considerably greater than with locking or has harmful side-effects. 28 28 29 29 === Inefficiencies === 30 30 31 When evaluating the inefficiencies, their impact should be considered in terms of their probability and overhead of the duplicated call. The duplicated case,31 When evaluating the inefficiencies, their impact should be considered as outlined above: probability, overhead and side effects. The duplicated case, 32 32 {{{ 33 33 1. thread 1: if not foo: true, needs initializing