view base/src/java/lang/ThreadLocal.d @ 125:c43718956f21 default tip

Updated the snippets status.
author Jacob Carlborg <doob@me.com>
date Thu, 11 Aug 2011 19:55:14 +0200
parents 9f4c18c268b2
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;
        }
    }
}