Created
June 10, 2013 03:29
-
-
Save miniway/5746350 to your computer and use it in GitHub Desktop.
An errno replacement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/main/java/zmq/Ctx.java b/src/main/java/zmq/Ctx.java | |
index c1703ca..a9780bf 100644 | |
--- a/src/main/java/zmq/Ctx.java | |
+++ b/src/main/java/zmq/Ctx.java | |
@@ -130,6 +130,8 @@ public class Ctx { | |
io_threads = new ArrayList<IOThread>(); | |
sockets = new ArrayList<SocketBase>(); | |
endpoints = new HashMap<String, Endpoint>(); | |
+ | |
+ ZError.clear(); | |
} | |
protected void destroy() { | |
diff --git a/src/main/java/zmq/ZError.java b/src/main/java/zmq/ZError.java | |
index 1cbc6fd..4f492cf 100644 | |
--- a/src/main/java/zmq/ZError.java | |
+++ b/src/main/java/zmq/ZError.java | |
@@ -20,6 +20,8 @@ package zmq; | |
import java.net.SocketException; | |
import java.nio.channels.ClosedChannelException; | |
+import java.util.concurrent.atomic.AtomicInteger; | |
+import java.util.concurrent.atomic.AtomicReference; | |
public class ZError { | |
@@ -41,14 +43,8 @@ public class ZError { | |
} | |
} | |
- private static ThreadLocal<Integer> errno = new ThreadLocal<Integer>() { | |
- | |
- protected synchronized Integer initialValue() { | |
- return new Integer(0); | |
- } | |
- }; | |
- | |
- private static ThreadLocal<Throwable> exc = new ThreadLocal<Throwable>(); | |
+ private static AtomicInteger errno = new AtomicInteger(0); | |
+ private static AtomicReference<Throwable> exc = new AtomicReference<Throwable>(); | |
public static final int EINTR = 4; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment