mirror of
https://github.com/gnosygnu/xowa.git
synced 2025-06-04 08:24:18 +00:00
Wbase: Add lock to pid_mgr else multi-threaded issues
This commit is contained in:
parent
265388a889
commit
f7558a6761
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
package gplx.xowa.addons.apps.cfgs.mgrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
package gplx.xowa.addons.apps.cfgs.mgrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||||
import org.junit.*; import gplx.core.tests.*; import gplx.dbs.*; import gplx.xowa.addons.apps.cfgs.dbs.*;
|
import org.junit.*; import gplx.core.tests.*; import gplx.dbs.*; import gplx.xowa.addons.apps.cfgs.dbs.*;
|
||||||
public class Xocfg_cache_mgr__tst {
|
public class Xocfg_cache_mgr__tst {
|
||||||
private final Xocfg_cache_mgr__fxt fxt = new Xocfg_cache_mgr__fxt();
|
// private final Xocfg_cache_mgr__fxt fxt = new Xocfg_cache_mgr__fxt();
|
||||||
@Test public void Basic() {
|
@Test public void Basic() {
|
||||||
// fxt.Init__db_add("en.w", "key_1", "val_1");
|
// fxt.Init__db_add("en.w", "key_1", "val_1");
|
||||||
// fxt.Test__get("en.w", "key_1", "val_1");
|
// fxt.Test__get("en.w", "key_1", "val_1");
|
||||||
|
@ -37,9 +37,11 @@ public class Wbase_pid_mgr { // EX: "en|road_map" -> 15 ("Property:P15")
|
|||||||
byte[] pid_key = Bry_.Add(lang_key, Byte_ascii.Pipe_bry, pid_name); // EX: "en|road_map"
|
byte[] pid_key = Bry_.Add(lang_key, Byte_ascii.Pipe_bry, pid_name); // EX: "en|road_map"
|
||||||
int rv = hash.Get_as_int_or(pid_key, -1);
|
int rv = hash.Get_as_int_or(pid_key, -1);
|
||||||
if (rv == -1) {
|
if (rv == -1) {
|
||||||
|
synchronized (hash) { // LOCK:app-level; DATE:2016-12-03
|
||||||
rv = wbase_mgr.Wdata_wiki().Db_mgr().Load_mgr().Load_pid(lang_key, pid_name); if (rv == Wdata_wiki_mgr.Pid_null) return rv;
|
rv = wbase_mgr.Wdata_wiki().Db_mgr().Load_mgr().Load_pid(lang_key, pid_name); if (rv == Wdata_wiki_mgr.Pid_null) return rv;
|
||||||
Add(pid_key, rv);
|
Add(pid_key, rv);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
public static int To_int_or_null(byte[] pid_ttl) { // EX: "p123" -> "123"
|
public static int To_int_or_null(byte[] pid_ttl) { // EX: "p123" -> "123"
|
||||||
|
Loading…
Reference in New Issue
Block a user