Changeset 762

Show
Ignore:
Timestamp:
06/25/08 13:03:09 (2 months ago)
Author:
Bartosz
Message:

Added symbolic names for constants. Defined TID_BITS--number of bits needed to store our compact thread ID

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/phobos/std/thread.d

    r749 r762  
    3131 * It is important to use the $(B Thread) class to create and manage 
    3232 * threads as the garbage collector needs to know about all the threads. 
     33 * 
     34 * Authors: Walter Bright, Bartosz Milewski 
     35 * 
    3336 * Macros: 
    3437 *      WIKI=Phobos/StdThread 
     
    400403    static uint nthreads = 1; 
    401404    static __thread uint myCompactThreadId; // 11-bit ((idx << 1) | 1) 
     405    enum uint TID_BITS = 11; 
    402406 
    403407  private: 
    404408 
    405409    static uint allThreadsDim; 
    406     static Thread[0x400] allThreads;    // length matches value in C runtime 
     410    enum uint MAX_THREADS = (1 << (TID_BITS - 1)); // 0x400 
     411    static Thread[MAX_THREADS] allThreads;  // length matches value in C runtime 
     412    static assert(MAX_THREADS == 0x400); 
    407413 
    408414    TS state; 
     
    921927    static uint nthreads = 1; 
    922928    static __thread uint myCompactThreadId; // 11-bit ((idx << 1) | 1) 
     929    enum uint TID_BITS = 11; 
    923930 
    924931  private: 
     
    929936    // pthread_create will fail gracefully if stack limit 
    930937    // is reached prior to allThreads max. 
    931     static Thread[0x400] allThreads; 
     938    enum uint MAX_THREADS = (1 << (TID_BITS - 1)); // 0x400 
     939    static Thread[MAX_THREADS] allThreads; 
     940    static assert(MAX_THREADS == 0x400); 
    932941 
    933942    static sem_t flagSuspend;