Add interruptor utilities

Expose wrapper functions for interrupting blocking calls, for process
and sockets.
This commit is contained in:
Romain Vimont
2021-11-12 18:50:50 +01:00
parent e0896142db
commit 40340509d9
5 changed files with 163 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
#include "process_intr.h"
bool
sc_process_check_success_intr(struct sc_intr *intr, sc_pid pid,
const char *name) {
if (!sc_intr_set_process(intr, pid)) {
// Already interrupted
return false;
}
// Always pass close=false, interrupting would be racy otherwise
bool ret = sc_process_check_success(pid, name, false);
sc_intr_set_process(intr, SC_PROCESS_NONE);
return ret;
}