The 2017 FRC Driver Station supports getting the robot IP via a TCP
connection that returns JSON. Use this to support overriding the
server IP address used for client connections.
Default to using this approach for client connections in the NetworkTable
interfaces.
Add support for setting the server address without stopping and
restarting the client.
SetTeam now also round-robins by default.
Moving these headers from src to include enables other libraries to use the
functionality provided.
* tcpsockets
* atomic_static
* raw_istream
* timestamp
* SafeThread
* Base64
* LEB128
* ConcurrentQueue
The classes have been moved into the wpi namespace as they're generic.
There was no way to atomically check for a key in the table,
and then setting if it if non existant. Back before persistent
this was not a problem, however now it is, as its possible for
values to be added before team's robot programs start. This makes
the old method of calling Put*** methods in RobotInit invalid.
This adds SetDefault methods, which do this atomically.
JavaGlobal was unconditionally attaching to (okay) and detaching from (bad)
the current thread during destruction. We don't want to do this if the
destructor gets called from an attached thread. Instead, use GetEnv to
first try to get the environment, and only attach and detach if it returns
an error saying the thread is detached.
Also, make sure notifier callbacks appropriately free Java locals to avoid
running out of local variable space.
During JVM shutdown, some JNI calls may not return, so it's not possible to
reliably perform a join() during static variable destruction (which occurs
as the JVM unloads the JNI module).
Also, due to static variable destruction, it's not safe to use any members
of a static class instance from a separate thread of execution.
SafeThread is a templated thread class and a related owner class that's
designed for safe operation and shutdown of threads in the presence of
callbacks that may not return. It also passes ownership of variables from
the static instance to the thread, so the thread can safely operate until
it exits (the last operation of the thread being to destroy its instance).
Notifiers, RpcServer, and Logger now use SafeThread to ensure race-free
destruction in both C++ and Java.
All Java callback threads are now marked as Java daemon threads so they
don't keep the JVM running after main() terminates.
All Java callback threads are now named so their purpose is more easily
identified in a debugger.
Add SetRpcServerOnStart and SetRpcServerOnExit (similar to Listener).
Each call to AttachCurrentThread results in a new Java thread object being
created. This is inefficient and also causes debugging issues with Eclipse
due to constant creation and removal of threads. Now AttachCurrentThread is
only called once for (all) listeners and once for logging (if used).
This enables listeners to be notified of not only value updates, but also flag
changes and deletions by using a bitmask to specify what notifications are
desired. The old API (which only provided a new/not new) flag is still
supported. This also subsumes the feature to listen to local changes (that's
one of the bitmask options).
The default behavior is to only notify remote changes, but for some
applications (e.g. GUI's) it's advantageous to know about local
changes as well.
This is (slightly) optimized in that local changes only result in
additional resources being consumed if (any) local listeners have been
created.
The JVM doesn't always do a good job of telling JNI modules that the JVM
is going away, which results in a crash in the JavaGlobal and/or
JavaWeakGlobal destructors as they try to delete the associated references
after the JVM has already gone away.
To protect against this, the Notifier now has a static variable that's set
when the Notifier instance (a singleton) is destroyed. This is used by
JavaGlobal and JavaWeakGlobal to detect when a process exit is in process.
The JNI bindings are built directly into the shared library. In the gradle
build, all built shared libraries are embedded into the generated jar.
Java bindings may be disabled via -DWITHOUT_JAVA (cmake) or -PskipJava=true
(gradle).
TODO:
- getEntryInfo() and RPC are not yet implemented.
- The cmake build doesn't integrate the built objects into the jar.
- The Java client and server tests are not built (but have been manually
tested).
This has not yet been tested on Windows.