diff options
author | Max Kellermann <max@musicpd.org> | 2019-04-25 18:33:09 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-04-25 19:46:43 +0200 |
commit | b51bae5500f8c9cc37708ca5130c9ee9866a0704 (patch) | |
tree | 8980f518daedc24a3b3f548738884e59aadd0d32 /src/thread | |
parent | 5bc8cd0ecbc06ed46335e01037412a66fd3811ae (diff) |
thread/*Cond: rename methods to match std::condition_variable
Diffstat (limited to 'src/thread')
-rw-r--r-- | src/thread/PosixCond.hxx | 14 | ||||
-rw-r--r-- | src/thread/WindowsCond.hxx | 16 |
2 files changed, 15 insertions, 15 deletions
diff --git a/src/thread/PosixCond.hxx b/src/thread/PosixCond.hxx index ab00a654f..32079635b 100644 --- a/src/thread/PosixCond.hxx +++ b/src/thread/PosixCond.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2015 Max Kellermann <max.kellermann@gmail.com> + * Copyright 2009-2019 Max Kellermann <max.kellermann@gmail.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -62,11 +62,11 @@ public: PosixCond(const PosixCond &other) = delete; PosixCond &operator=(const PosixCond &other) = delete; - void signal() noexcept { + void notify_one() noexcept { pthread_cond_signal(&cond); } - void broadcast() noexcept { + void notify_all() noexcept { pthread_cond_broadcast(&cond); } @@ -75,7 +75,7 @@ public: } private: - bool timed_wait(PosixMutex &mutex, uint_least32_t timeout_us) noexcept { + bool wait_for(PosixMutex &mutex, uint_least32_t timeout_us) noexcept { struct timeval now; gettimeofday(&now, nullptr); @@ -92,15 +92,15 @@ private: } public: - bool timed_wait(PosixMutex &mutex, - std::chrono::steady_clock::duration timeout) noexcept { + bool wait_for(PosixMutex &mutex, + std::chrono::steady_clock::duration timeout) noexcept { auto timeout_us = std::chrono::duration_cast<std::chrono::microseconds>(timeout).count(); if (timeout_us < 0) timeout_us = 0; else if (timeout_us > std::numeric_limits<uint_least32_t>::max()) timeout_us = std::numeric_limits<uint_least32_t>::max(); - return timed_wait(mutex, timeout_us); + return wait_for(mutex, timeout_us); } }; diff --git a/src/thread/WindowsCond.hxx b/src/thread/WindowsCond.hxx index 108f38c81..ef2777baf 100644 --- a/src/thread/WindowsCond.hxx +++ b/src/thread/WindowsCond.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2013 Max Kellermann <max.kellermann@gmail.com> + * Copyright 2009-2019 Max Kellermann <max.kellermann@gmail.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -48,29 +48,29 @@ public: WindowsCond(const WindowsCond &other) = delete; WindowsCond &operator=(const WindowsCond &other) = delete; - void signal() noexcept { + void notify_one() noexcept { WakeConditionVariable(&cond); } - void broadcast() noexcept { + void notify_all() noexcept { WakeAllConditionVariable(&cond); } private: - bool timed_wait(CriticalSection &mutex, DWORD timeout_ms) noexcept { + bool wait_for(CriticalSection &mutex, DWORD timeout_ms) noexcept { return SleepConditionVariableCS(&cond, &mutex.critical_section, timeout_ms); } public: - bool timed_wait(CriticalSection &mutex, - std::chrono::steady_clock::duration timeout) noexcept { + bool wait_for(CriticalSection &mutex, + std::chrono::steady_clock::duration timeout) noexcept { auto timeout_ms = std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count(); - return timed_wait(mutex, timeout_ms); + return wait_for(mutex, timeout_ms); } void wait(CriticalSection &mutex) noexcept { - timed_wait(mutex, INFINITE); + wait_for(mutex, INFINITE); } }; |