void set_task(Task& func) { verify(!func.empty()); verify(_is_done); _is_done = false; _task.put(func); }
void set_task(Task& func) { assert(!func.empty()); assert(_is_done); _is_done = false; _task.put(func); }
void loop() { while (true) { Task task = _task.take(); if (task.empty()) { break; // ends the thread } try { task(); } catch (std::exception e) { log() << "Unhandled exception in worker thread: " << e.what() << endl;; } catch (...) { log() << "Unhandled non-exception in worker thread" << endl; } _is_done = true; _owner.task_done(this); } }