This commit is contained in:
mutouyun 2019-03-20 23:42:18 +08:00
parent 4049e78c32
commit b65be99045
4 changed files with 9 additions and 9 deletions

View File

@ -71,7 +71,7 @@ inline void yield(K& k) noexcept {
}
template <std::size_t N = 4096, typename K, typename F>
inline void sleep(K& k, F&& f) noexcept {
inline void sleep(K& k, F&& f) {
if (k < static_cast<K>(N)) {
std::this_thread::yield();
}
@ -86,7 +86,7 @@ inline void sleep(K& k, F&& f) noexcept {
}
template <std::size_t N = 4096, typename K>
inline void sleep(K& k) noexcept {
inline void sleep(K& k) {
sleep<N>(k, [] { return false; });
}

View File

@ -105,9 +105,9 @@ public:
#pragma pop_macro("IPC_PTHREAD_FUNC_")
class semaphore {
mutex lock_;
condition cond_;
long volatile counter_;
mutex lock_;
condition cond_;
long counter_;
public:
bool open(long count = 0) {

View File

@ -62,7 +62,7 @@ class condition {
mutex lock_;
semaphore sema_, handshake_;
long volatile * counter_ = nullptr;
long * counter_ = nullptr;
public:
friend bool operator==(condition const & c1, condition const & c2) {
@ -73,7 +73,7 @@ public:
return !(c1 == c2);
}
bool open(std::string const & name, long volatile * counter) {
bool open(std::string const & name, long * counter) {
if (lock_ .open(name + "__COND_MTX__") &&
sema_ .open(name + "__COND_SEM__") &&
handshake_.open(name + "__COND_HAN__")) {
@ -130,7 +130,7 @@ public:
};
class waiter {
long volatile counter_ = 0;
long counter_ = 0;
public:
using handle_t = condition;

View File

@ -25,7 +25,7 @@ class condition_impl : public ipc::detail::condition {
public:
bool open(std::string const & name) {
if (h_.acquire((name + "__COND_CNT__").c_str(), sizeof(long volatile))) {
return ipc::detail::condition::open(name, static_cast<long volatile*>(h_.get()));
return ipc::detail::condition::open(name, static_cast<long *>(h_.get()));
}
return false;
}