Changes between Version 45 and Version 46 of DjangoSpecifications/Core/Threading


Ignore:
Timestamp:
04/26/2008 03:50:37 PM (7 years ago)
Author:
mrts
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DjangoSpecifications/Core/Threading

    v45 v46  
    1616The main pattern of global variable usage in Django is ''use `var` if initialized, otherwise initialize''. This is generally not thread-safe.
    1717
    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),
    2020 * errors due to incomplete initialization.
    2121
     
    2525 * locking would needlessly penalize single-threaded execution.
    2626
    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.
     27Thus, 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.
    2828
    2929=== Inefficiencies ===
    3030
    31 When evaluating the inefficiencies, their impact should be considered in terms of their probability and overhead of the duplicated call. The duplicated case,
     31When evaluating the inefficiencies, their impact should be considered as outlined above: probability, overhead and side effects. The duplicated case,
    3232{{{
    33331. thread 1: if not foo: true, needs initializing
Back to Top