From d01d04ef85f6baddab52792b32a74b543acc6175 Mon Sep 17 00:00:00 2001 From: heck Date: Tue, 3 Mar 2020 03:03:38 +0100 Subject: [PATCH] Synchronized the method Engine.myself(). Seems to solve the problem. Enhanced DSL keyword "basic" with a "sync" option. Increased threads count in tests to 2000 --- src/gen_java_Engine.ysl2 | 12 +++++++++++- src/pEp.yml2 | 32 ++++++++++++++++---------------- test/JNI_88/JNI_88.java | 2 +- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/gen_java_Engine.ysl2 b/src/gen_java_Engine.ysl2 index 51ed0ed..9e6a023 100644 --- a/src/gen_java_Engine.ysl2 +++ b/src/gen_java_Engine.ysl2 @@ -25,9 +25,19 @@ tstylesheet { || } + function "syncmode" { + param "sync"; + + choose { + when "$sync='sync'" > synchronized + otherwise value "''"; + } + } + template "basic" { const "itype" call "toIntermediate" with "type", "@type"; const "jtype" call "toJava" with "type", "@type"; + const "sync" call "syncmode" with "sync", "@sync"; choose { when "name(parm/*[1])='bytearray'" @@ -39,7 +49,7 @@ tstylesheet { || private native «$itype» «@name»(`apply "parm/*", mode=basic_iparm`); - public «$jtype» «@name»(`apply "parm/*", mode=basic_parm`) { + public «$sync» «$jtype» «@name»(`apply "parm/*", mode=basic_parm`) { || apply "parm/*", mode=basic_parm_set; choose { diff --git a/src/pEp.yml2 b/src/pEp.yml2 index c335d7c..1c03566 100644 --- a/src/pEp.yml2 +++ b/src/pEp.yml2 @@ -4,7 +4,7 @@ decl interface @name; decl exception @name; decl method @name; decl struct @name; -decl basic @type @name; +decl basic @sync @type @name; namespace pEp { exception Status { @@ -249,21 +249,21 @@ namespace pEp { in CipherSuite suite ); - basic string trustwords(identity ident); - basic identity myself(identity ident); - basic identity updateIdentity(identity ident); - basic identity setOwnKey(identity ident, string fpr); - basic void keyMistrusted(identity ident); - basic void keyResetTrust(identity ident); - basic void trustPersonalKey(identity ident); - basic void trustOwnKey(identity ident); - basic void importKey(bytearray key); - basic void blacklist_add(string fpr); - basic void blacklist_delete(string fpr); - basic bool blacklist_is_listed(string fpr); - basic void config_passive_mode(bool enable); - basic void config_unencrypted_subject(bool enable); - basic string getCrashdumpLog(int maxlines); + basic none string trustwords(identity ident); + basic sync identity myself(identity ident); + basic none identity updateIdentity(identity ident); + basic none identity setOwnKey(identity ident, string fpr); + basic none void keyMistrusted(identity ident); + basic none void keyResetTrust(identity ident); + basic none void trustPersonalKey(identity ident); + basic none void trustOwnKey(identity ident); + basic none void importKey(bytearray key); + basic none void blacklist_add(string fpr); + basic none void blacklist_delete(string fpr); + basic none bool blacklist_is_listed(string fpr); + basic none void config_passive_mode(bool enable); + basic none void config_unencrypted_subject(bool enable); + basic none string getCrashdumpLog(int maxlines); }; struct message { diff --git a/test/JNI_88/JNI_88.java b/test/JNI_88/JNI_88.java index 9a292a5..2fa18e8 100644 --- a/test/JNI_88/JNI_88.java +++ b/test/JNI_88/JNI_88.java @@ -97,7 +97,7 @@ class JNI_88 { public static void main(String[] args) { // Test parameters boolean useSharedEngine = true; - int numThreads = 2; + int numThreads = 2000; int numIters = 1000000000; Engine sharedEngine = null;