view base/src/java/lang/ThreadLocal.d @ 112:9f4c18c268b2

Update to compile and execute with dmd 2.052.
author kntroh
date Wed, 16 Mar 2011 21:53:53 +0900
parents 5d5bd660917f
children
line wrap: on
line source

module java.lang.ThreadLocal;
import java.lang.util;

version(Tango){
    static import tango.core.Thread;

    class ThreadLocal{
        alias tango.core.Thread.ThreadLocal!(Object) TLSType;
        TLSType tls;
        this(){
            tls = new TLSType( initialValue() );
        }
        Object get(){
            return tls.val();
        }
        protected  Object initialValue(){
            return null;
        }
        void set(Object value){
            return tls.val( value );
        }
    }
} else { // Phobos
    class ThreadLocal{
        Object tls;
        this(){
            tls = initialValue();
        }
        Object get(){
            return tls;
        }
        protected  Object initialValue(){
            return null;
        }
        void set(Object value){
            return tls = value;
        }
    }
}