mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 08:46:45 +08:00
Update semaphore_linux.h
This commit is contained in:
parent
d37a6740ea
commit
cd4b28380c
@ -60,7 +60,7 @@ public:
|
||||
}
|
||||
|
||||
bool wait(std::uint64_t tm) noexcept {
|
||||
if (h == invalid()) return false;
|
||||
if (!valid()) return false;
|
||||
switch (tm) {
|
||||
case 0:
|
||||
return true;
|
||||
@ -72,7 +72,7 @@ public:
|
||||
return true;
|
||||
default: {
|
||||
auto ts = detail::make_timespec(tm);
|
||||
if (::sem_timedwait(h, &ts) != 0) {
|
||||
if (::sem_timedwait(h_, &ts) != 0) {
|
||||
if (errno != ETIMEDOUT) {
|
||||
ipc::error("fail sem_timedwait[%d]: tm = %zd, tv_sec = %ld, tv_nsec = %ld\n",
|
||||
errno, tm, ts.tv_sec, ts.tv_nsec);
|
||||
@ -85,7 +85,7 @@ public:
|
||||
}
|
||||
|
||||
bool post(std::uint32_t count) noexcept {
|
||||
if (h_ == invalid()) return false;
|
||||
if (!valid()) return false;
|
||||
for (std::uint32_t i = 0; i < count; ++i) {
|
||||
if (::sem_post(h_) != 0) {
|
||||
ipc::error("fail sem_post[%d]: %s\n", errno);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user