mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpiutil] jni_util: Add JSpan and CriticalJSpan (#5554)
These replace JArrayRef et al and support statically sized arrays similar to std::span.
This commit is contained in:
@@ -275,11 +275,11 @@ JNIEXPORT jintArray JNICALL
|
||||
Java_edu_wpi_first_util_WPIUtilJNI_waitForObjects
|
||||
(JNIEnv* env, jclass, jintArray handles)
|
||||
{
|
||||
JIntArrayRef handlesArr{env, handles};
|
||||
JSpan<const jint> handlesArr{env, handles};
|
||||
wpi::SmallVector<WPI_Handle, 8> signaledBuf;
|
||||
signaledBuf.resize(handlesArr.size());
|
||||
std::span<const WPI_Handle> handlesArr2{
|
||||
reinterpret_cast<const WPI_Handle*>(handlesArr.array().data()),
|
||||
reinterpret_cast<const WPI_Handle*>(handlesArr.data()),
|
||||
handlesArr.size()};
|
||||
|
||||
auto signaled = wpi::WaitForObjects(handlesArr2, signaledBuf);
|
||||
@@ -299,11 +299,11 @@ JNIEXPORT jintArray JNICALL
|
||||
Java_edu_wpi_first_util_WPIUtilJNI_waitForObjectsTimeout
|
||||
(JNIEnv* env, jclass, jintArray handles, jdouble timeout)
|
||||
{
|
||||
JIntArrayRef handlesArr{env, handles};
|
||||
JSpan<const jint> handlesArr{env, handles};
|
||||
wpi::SmallVector<WPI_Handle, 8> signaledBuf;
|
||||
signaledBuf.resize(handlesArr.size());
|
||||
std::span<const WPI_Handle> handlesArr2{
|
||||
reinterpret_cast<const WPI_Handle*>(handlesArr.array().data()),
|
||||
reinterpret_cast<const WPI_Handle*>(handlesArr.data()),
|
||||
handlesArr.size()};
|
||||
|
||||
bool timedOut;
|
||||
|
||||
Reference in New Issue
Block a user