Hello all
I'm wrapping a third party library that has some global structures that
could potentially get corrupted if more than one thread calls into the
native code at any given time.
However, due to the nature of my problem, I foresee that I might have more
than one Java thread that might be calling into this library.
I think I want to synchronize access to the library. One option would be to
write all my code as:
synchronized (MyLib.INSTANCE) {
MyLib.INSTANCE.foo();
}
but this seems rather repetitive and error prone, so I'm hoping JNA could
help out.
In general, it seems like it might be useful to have a mechanism to be able
to register "functors" to be invoked just before and just after JNA calls
the native library. One could configure this similarly to the type and
function mappers.
If such a mechanism existed (or exists?), I could register a "lock" and a
"unlock" functor to manage a Lock to synchronize access to the native
library.
Any thoughts?
Regards,
Albert