mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-07-08 05:51:17 -07:00
clang-format this branch
This commit is contained in:
parent
8b77ef538a
commit
342fa9d33f
135 changed files with 42729 additions and 42439 deletions
186
node/Mutex.hpp
186
node/Mutex.hpp
|
@ -27,60 +27,60 @@ namespace ZeroTier {
|
|||
// libpthread based mutex lock
|
||||
class Mutex {
|
||||
public:
|
||||
Mutex()
|
||||
{
|
||||
pthread_mutex_init(&_mh, (const pthread_mutexattr_t*)0);
|
||||
}
|
||||
Mutex()
|
||||
{
|
||||
pthread_mutex_init(&_mh, (const pthread_mutexattr_t*)0);
|
||||
}
|
||||
|
||||
~Mutex()
|
||||
{
|
||||
pthread_mutex_destroy(&_mh);
|
||||
}
|
||||
~Mutex()
|
||||
{
|
||||
pthread_mutex_destroy(&_mh);
|
||||
}
|
||||
|
||||
inline void lock() const
|
||||
{
|
||||
pthread_mutex_lock(&((const_cast<Mutex*>(this))->_mh));
|
||||
}
|
||||
inline void lock() const
|
||||
{
|
||||
pthread_mutex_lock(&((const_cast<Mutex*>(this))->_mh));
|
||||
}
|
||||
|
||||
inline void unlock() const
|
||||
{
|
||||
pthread_mutex_unlock(&((const_cast<Mutex*>(this))->_mh));
|
||||
}
|
||||
inline void unlock() const
|
||||
{
|
||||
pthread_mutex_unlock(&((const_cast<Mutex*>(this))->_mh));
|
||||
}
|
||||
|
||||
class Lock {
|
||||
public:
|
||||
Lock(Mutex& m) : _m(&m)
|
||||
{
|
||||
m.lock();
|
||||
}
|
||||
class Lock {
|
||||
public:
|
||||
Lock(Mutex& m) : _m(&m)
|
||||
{
|
||||
m.lock();
|
||||
}
|
||||
|
||||
Lock(const Mutex& m) : _m(const_cast<Mutex*>(&m))
|
||||
{
|
||||
_m->lock();
|
||||
}
|
||||
Lock(const Mutex& m) : _m(const_cast<Mutex*>(&m))
|
||||
{
|
||||
_m->lock();
|
||||
}
|
||||
|
||||
~Lock()
|
||||
{
|
||||
_m->unlock();
|
||||
}
|
||||
~Lock()
|
||||
{
|
||||
_m->unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
Mutex* const _m;
|
||||
};
|
||||
private:
|
||||
Mutex* const _m;
|
||||
};
|
||||
|
||||
private:
|
||||
Mutex(const Mutex&)
|
||||
{
|
||||
}
|
||||
const Mutex& operator=(const Mutex&)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
Mutex(const Mutex&)
|
||||
{
|
||||
}
|
||||
const Mutex& operator=(const Mutex&)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
pthread_mutex_t _mh;
|
||||
pthread_mutex_t _mh;
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
} // namespace ZeroTier
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -94,71 +94,71 @@ namespace ZeroTier {
|
|||
// Windows critical section based lock
|
||||
class Mutex {
|
||||
public:
|
||||
Mutex()
|
||||
{
|
||||
InitializeCriticalSection(&_cs);
|
||||
}
|
||||
Mutex()
|
||||
{
|
||||
InitializeCriticalSection(&_cs);
|
||||
}
|
||||
|
||||
~Mutex()
|
||||
{
|
||||
DeleteCriticalSection(&_cs);
|
||||
}
|
||||
~Mutex()
|
||||
{
|
||||
DeleteCriticalSection(&_cs);
|
||||
}
|
||||
|
||||
inline void lock()
|
||||
{
|
||||
EnterCriticalSection(&_cs);
|
||||
}
|
||||
inline void lock()
|
||||
{
|
||||
EnterCriticalSection(&_cs);
|
||||
}
|
||||
|
||||
inline void unlock()
|
||||
{
|
||||
LeaveCriticalSection(&_cs);
|
||||
}
|
||||
inline void unlock()
|
||||
{
|
||||
LeaveCriticalSection(&_cs);
|
||||
}
|
||||
|
||||
inline void lock() const
|
||||
{
|
||||
(const_cast<Mutex*>(this))->lock();
|
||||
}
|
||||
inline void lock() const
|
||||
{
|
||||
(const_cast<Mutex*>(this))->lock();
|
||||
}
|
||||
|
||||
inline void unlock() const
|
||||
{
|
||||
(const_cast<Mutex*>(this))->unlock();
|
||||
}
|
||||
inline void unlock() const
|
||||
{
|
||||
(const_cast<Mutex*>(this))->unlock();
|
||||
}
|
||||
|
||||
class Lock {
|
||||
public:
|
||||
Lock(Mutex& m) : _m(&m)
|
||||
{
|
||||
m.lock();
|
||||
}
|
||||
class Lock {
|
||||
public:
|
||||
Lock(Mutex& m) : _m(&m)
|
||||
{
|
||||
m.lock();
|
||||
}
|
||||
|
||||
Lock(const Mutex& m) : _m(const_cast<Mutex*>(&m))
|
||||
{
|
||||
_m->lock();
|
||||
}
|
||||
Lock(const Mutex& m) : _m(const_cast<Mutex*>(&m))
|
||||
{
|
||||
_m->lock();
|
||||
}
|
||||
|
||||
~Lock()
|
||||
{
|
||||
_m->unlock();
|
||||
}
|
||||
~Lock()
|
||||
{
|
||||
_m->unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
Mutex* const _m;
|
||||
};
|
||||
private:
|
||||
Mutex* const _m;
|
||||
};
|
||||
|
||||
private:
|
||||
Mutex(const Mutex&)
|
||||
{
|
||||
}
|
||||
const Mutex& operator=(const Mutex&)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
Mutex(const Mutex&)
|
||||
{
|
||||
}
|
||||
const Mutex& operator=(const Mutex&)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
CRITICAL_SECTION _cs;
|
||||
CRITICAL_SECTION _cs;
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
} // namespace ZeroTier
|
||||
|
||||
#endif // _WIN32
|
||||
#endif // _WIN32
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue