openlvc/portico — pull request #39 by timpokorny (2014-10-19 06:45:42+00:00)
Title: PR #36 - `JNIEnv` caching changes to better support multithreaded environments

This PR extends on PR #36. In that request, there were a number of small changes to the C++ interface, as well as a change to the way the `JNIEnv` references used by the C++ bindings were being managed.

Previously, both the `hla13` and `ieee1516e` interfaces took the approach of caching a single `JNIEnv*` that was then used everywhere it was needed. However, each reference is only valid for a particular thread. So if you have a second or third thread running requests through the `RTIambassador`, things go to pieces as the reference isn't valid (and down things come crashing).

Ray made the change to the `ieee1516e` interface to replace all places where the cached version was accessed with a call to a method that first checked whether there was a valid reference for the current thread (reasonably cheap), and if not, attached it to the JVM. I've pushed a few commits on the top to ensure everything builds across all platforms and make sure the same change rolls out for the `hla13` interface.

Time to get Ray's good work into build.