<
bool()> & is_done_cb,
60 const function<
void(
bool*)> & update_result_cb)
64 if(timeout_mks != INT_MAX && timeout_mks > 0) {
65ns = (
int64_t)timeout_mks * 1000LL;
67ns = ns % 1000000000L;
75 if(!rv && timeout_mks) {
80 if(timeout_mks == INT_MAX) {
90 if(!rv && timeout_mks > 0) {
98 if(update_result_cb) {
99update_result_cb(&rv);
107 voidCFutex::DoWake(
intwaiters)
109 intrt = syscall(__NR_futex, &
m_Value, FUTEX_WAKE, waiters,
NULL);
112 string(
"CFutex::DoWake: failed, unexpected errno: ") +
120 structtimespec timeout = {0, 0};
121 structtimespec * ptimeout = &timeout;
123 if(timeout_mks < 0) {
126timeout.tv_sec = timeout_mks / 1000000L;
127timeout.tv_nsec = (timeout_mks % 1000000L) * 1000L;
130 while(syscall(__NR_futex, &
m_Value, FUTEX_WAIT,
value, ptimeout, 0, 0) != 0) {
134 returneWaitResultOkFast;
138 returneWaitResultTimeOut;
141 string(
"CFutex::WaitWhile: failed, unexpected errno: ") +
145 returneWaitResultOk;
154 CFutexSSignalHandler::sm_CtrlCPressedEvent;
167sm_CtrlCPressedEvent.Set(0);
177 sm_WatchThread= unique_ptr<thread,
function<void(thread*)> >(
newthread(
180signal(SIGINT, [](
int) {
181signal(SIGINT, SIG_DFL);
184SSignalHandler::sm_CtrlCPressedEvent.Inc();
189 while(SSignalHandler::sm_CtrlCPressedEvent.WaitWhile(
190SSignalHandler::sm_CtrlCPressedEvent.Inc(),
191100000) == CFutex::eWaitResultTimeOut && !
sm_Quit);
195 ERR_POST(
Trace<<
"Ctr+C watcher thread: calling closure");
205signal(SIGINT, SIG_DFL);
#define BEGIN_IDBLOB_SCOPE
BEGIN_IDBLOB_SCOPE USING_NCBI_SCOPE
bool WaitCondVar(unsigned int timeout_mks, CFastMutex &mux, CConditionVariable &ev, const function< bool()> &is_done_cb, const function< void(bool *)> &update_result_cb)
Wrapper around Linux's futex.
volatile int m_Value
Value of the futex.
EWaitResult
Type of result returned from WaitValueChange()
static unique_ptr< thread, function< void(thread *)> > sm_WatchThread
static volatile sig_atomic_t sm_CtrlCPressed
SSignalHandler.
static function< void()> sm_OnCtrlCPressed
static volatile bool sm_Quit
static void s_WatchCtrlCPressed(bool enable, function< void()> on_ctrl_c_pressed=NULL)
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Trace(CExceptionArgs_Base &args)
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
bool WaitForSignal(CMutex &mutex, const CDeadline &deadline=CDeadline::eInfinite)
Release mutex and lock the calling thread until the condition variable is signalled.
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n th
const GenericPointer< typename T::ValueType > T2 value
Multi-threading â classes, functions, and features.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4