Browse Source

[java] Tls implementation

Caue Waneck 12 years ago
parent
commit
b8ca613506
1 changed files with 27 additions and 0 deletions
  1. 27 0
      std/java/vm/Tls.hx

+ 27 - 0
std/java/vm/Tls.hx

@@ -0,0 +1,27 @@
+package java.vm;
+
+/**
+	Thread-local Storage implementation
+**/
+@:native('haxe.java.vm.Tls') class Tls<T>
+{
+	var t : java.lang.ThreadLocal<T>;
+	public var value(get,set):T;
+
+	public function new()
+	{
+		this.t = new java.lang.ThreadLocal();
+	}
+
+	inline private function get_value():T
+	{
+		return t.get();
+	}
+
+	inline private function set_value(v:T):T
+	{
+		t.set(v);
+		return v;
+	}
+
+}