Skip to content

Commit 1f9196a

Browse files
committed
Refactoring
1 parent 3790e4e commit 1f9196a

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

threadpool.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,18 @@ void ThreadPool::post_sem(sem_t* const sem)
207207

208208
void ThreadPool::wait_sem(sem_t* const sem)
209209
{
210-
for (;;) {
211-
int ret = sem_wait(sem);
212-
if (0 == ret) {
213-
return;
214-
}
210+
int ret = 0;
211+
do {
212+
ret = sem_wait(sem);
213+
} while (0 != ret && EINTR == errno);
215214

216-
switch (errno) {
217-
case EINTR:
218-
break;
219-
case EINVAL:
220-
throw Error("EINVAL returned by sem_wait()");
221-
default:
222-
throw Error("UNKNOWN returned by sem_wait()");
223-
}
215+
if (0 == ret) return;
216+
217+
switch (errno) {
218+
case EINVAL:
219+
throw Error("EINVAL returned by sem_wait()");
220+
default:
221+
throw Error("UNKNOWN returned by sem_wait()");
224222
}
225223
}
226224

0 commit comments

Comments
 (0)