From 27aa37946e56a4d9722de416791a2e40dc5d2054 Mon Sep 17 00:00:00 2001 From: George Karpenkov Date: Mon, 13 Jun 2016 12:09:34 +0200 Subject: [PATCH] Do not lock on context creation and deletion. --- src/api/java/Context.java | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/api/java/Context.java b/src/api/java/Context.java index 41fb027fe..e66920441 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -31,12 +31,7 @@ public class Context implements AutoCloseable { static final Object creation_lock = new Object(); public static Context mkContext() { - long m_ctx; - synchronized (creation_lock) { - m_ctx = Native.mkContextRc(0); - // TODO: then adding settings will not be under the lock. - } - return new Context(m_ctx); + return new Context(Native.mkContextRc(0)); } @@ -59,14 +54,11 @@ public class Context implements AutoCloseable { **/ public static Context mkContext(Map settings) { - long m_ctx; - synchronized (creation_lock) { - long cfg = Native.mkConfig(); - for (Map.Entry kv : settings.entrySet()) - Native.setParamValue(cfg, kv.getKey(), kv.getValue()); - m_ctx = Native.mkContextRc(cfg); - Native.delConfig(cfg); - } + long cfg = Native.mkConfig(); + for (Map.Entry kv : settings.entrySet()) + Native.setParamValue(cfg, kv.getKey(), kv.getValue()); + long m_ctx = Native.mkContextRc(cfg); + Native.delConfig(cfg); return new Context(m_ctx); } @@ -4047,8 +4039,6 @@ public class Context implements AutoCloseable { m_realSort = null; m_stringSort = null; - synchronized (creation_lock) { - Native.delContext(m_ctx); - } + Native.delContext(m_ctx); } }