Use wpi mutex and condition_variable. (#52)

This commit is contained in:
Peter Johnson
2017-11-12 22:12:03 -08:00
committed by GitHub
parent e45b6e0f65
commit 80618a2e64
4 changed files with 31 additions and 29 deletions

View File

@@ -8,7 +8,6 @@
#ifndef WPIUTIL_SUPPORT_JNI_UTIL_H_
#define WPIUTIL_SUPPORT_JNI_UTIL_H_
#include <mutex>
#include <string>
#include <type_traits>
#include <queue>
@@ -24,6 +23,7 @@
#include "llvm/StringRef.h"
#include "support/atomic_static.h"
#include "support/deprecated.h"
#include "support/mutex.h"
#include "support/SafeThread.h"
namespace wpi {
@@ -473,7 +473,7 @@ void JCallbackThread<T>::Main() {
jint rs = T::GetJVM()->AttachCurrentThreadAsDaemon((void**)&env, &args);
if (rs != JNI_OK) return;
std::unique_lock<std::mutex> lock(m_mutex);
std::unique_lock<wpi::mutex> lock(m_mutex);
while (m_active) {
m_cond.wait(lock, [&] { return !(m_active && m_queue.empty()); });
if (!m_active) break;