stevedlawrence commented on a change in pull request #343: Daffodil 2302 fixes
external variables API difficulties
URL: https://github.com/apache/incubator-daffodil/pull/343#discussion_r400878130
##########
File path: daffodil-japi/src/main/scala/org/apache/daffodil/japi/Daffodil.scala
##########
@@ -257,7 +264,7 @@ class Compiler private[japi] () {
* @param tunables a map of key/value pairs, where the key is the tunable
name and the value is the value to set it to
*/
def setTunables(tunables: java.util.AbstractMap[String, String]): Unit = {
- sCompiler.setTunables(tunables.asScala.toMap)
+ sCompiler = sCompiler.withTunables(tunables.asScala.toMap)
Review comment:
True, but there are still things people need to be careful of, e.g.
```scala
ThreadOne {
dp.setVariable(...)
dp.parse(...)
}
ThreadTwo {
dp.setVariable(...)
dp.parse(...)
}
```
The dp's in the separate threads still share state and so depending on the
orer of when setVariable and parse get called, they might affect each other.
Also, if feels like you've done all the hard work (this definitely turned
into a bigger change than I thought it'd be). If we did add new ``with*``
functions to the J/SAPI, wouldn't it look something like:
```scala
def withTunable(args): Compiler = {
val newSCompiler = sCompiler.withTunable(args)
new Compiler(newSCompiler)
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services