Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/org/adblockplus/android/api/JniExceptionHandler.java

Issue 6606493159784448: New JNI bindings (Closed)
Patch Set: Created March 14, 2014, 11:32 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/org/adblockplus/android/api/FilterEngine.java ('k') | src/org/adblockplus/android/api/JsEngine.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/org/adblockplus/android/api/JniExceptionHandler.java
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/org/adblockplus/android/api/JniExceptionHandler.java
@@ -0,0 +1,52 @@
+package org.adblockplus.android.api;
+
+import java.util.concurrent.LinkedBlockingQueue;
+
+public final class JniExceptionHandler
+{
+ private static LogWorker logWorker = null;
+
+ static
+ {
+ logWorker = new LogWorker();
+ final Thread t = new Thread(logWorker);
+ t.setDaemon(true);
+ t.start();
+ }
+
+ public static void logException(final Throwable t)
+ {
+ logWorker.logException(t);
+ }
+
+ private final static class LogWorker implements Runnable
+ {
+ LinkedBlockingQueue<Throwable> exceptionQueue = new LinkedBlockingQueue<Throwable>();
+
+ private void logException(final Throwable t)
+ {
+ this.exceptionQueue.offer(t);
+ }
+
+ @Override
+ public void run()
+ {
+ for (;;)
+ {
+ try
+ {
+ final Throwable t = this.exceptionQueue.take();
+ System.err.println("EXCEPTION: " + t);
+ }
+ catch (final InterruptedException ie)
+ {
+ break;
+ }
+ catch (final Throwable ex)
+ {
+ // TODO: Swallow or log?
+ }
+ }
+ }
+ }
+}
« no previous file with comments | « src/org/adblockplus/android/api/FilterEngine.java ('k') | src/org/adblockplus/android/api/JsEngine.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld