updated core to 1.2.4, fixed pico_device init bug
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/
|
||||
* Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -14,6 +14,14 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* You can be released from the requirements of the license by purchasing
|
||||
* a commercial license. Buying such a license is mandatory as soon as you
|
||||
* develop commercial closed-source software that incorporates or links
|
||||
* directly against ZeroTier software without disclosing the source code
|
||||
* of your own application.
|
||||
*/
|
||||
|
||||
#ifndef ZT_BLOCKINGQUEUE_HPP
|
||||
@@ -34,7 +42,7 @@ template <class T>
|
||||
class BlockingQueue
|
||||
{
|
||||
public:
|
||||
BlockingQueue(void) {}
|
||||
BlockingQueue(void) : r(true) {}
|
||||
|
||||
inline void post(T t)
|
||||
{
|
||||
@@ -43,19 +51,34 @@ public:
|
||||
c.notify_one();
|
||||
}
|
||||
|
||||
inline T get(void)
|
||||
inline void stop(void)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
r = false;
|
||||
c.notify_all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value Value to set to next queue item if return value is true
|
||||
* @return False if stop() has been called, true otherwise
|
||||
*/
|
||||
inline bool get(T &value)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m);
|
||||
while(q.empty())
|
||||
if (!r) return false;
|
||||
while (q.empty()) {
|
||||
c.wait(lock);
|
||||
T val = q.front();
|
||||
if (!r) return false;
|
||||
}
|
||||
value = q.front();
|
||||
q.pop();
|
||||
return val;
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
volatile bool r;
|
||||
std::queue<T> q;
|
||||
mutable std::mutex m;
|
||||
std::mutex m;
|
||||
std::condition_variable c;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user