void logger::stop() { #if CAF_LOG_LEVEL >= 0 if (has(inline_output_flag)) { log_last_line(); return; } if (!thread_.joinable()) return; // an empty string means: shut down queue_.synchronized_push_back(queue_mtx_, queue_cv_, new event); thread_.join(); #endif }
static void really_define_key(WINDOW *win, const char *new_string, int code) { int rc; const char *code_name = keyname(code); char *old_string; char *vis_string = 0; char temp[80]; if (code_name == 0) { sprintf(temp, "Keycode %d", code); code_name = temp; } if ((old_string = keybound(code, 0)) != 0) { wprintw(win, "%s is %s\n", code_name, vis_string = visible(old_string)); } else { wprintw(win, "%s is not bound\n", code_name); } log_last_line(win); if (vis_string != 0) { free(vis_string); vis_string = 0; } vis_string = visible(new_string); if ((rc = key_defined(new_string)) > 0) { wprintw(win, "%s was bound to %s\n", vis_string, keyname(rc)); log_last_line(win); } else if (new_string != 0 && rc < 0) { wprintw(win, "%s conflicts with longer strings\n", vis_string); log_last_line(win); } rc = define_key(new_string, code); if (rc == ERR) { wprintw(win, "%s unchanged\n", code_name); log_last_line(win); } else if (new_string != 0) { wprintw(win, "%s is now bound to %s\n", vis_string, code_name); log_last_line(win); } else if (old_string != 0) { wprintw(win, "%s deleted\n", code_name); log_last_line(win); } if (vis_string != 0) free(vis_string); if (old_string != 0) free(old_string); }
void logger::run() { #if CAF_LOG_LEVEL >= 0 log_first_line(); // receive log entries from other threads and actors bool stop = false; auto f = [&](event& x) { // empty message means: shut down if (x.message.empty()) { stop = true; return intrusive::task_result::stop; } handle_event(x); return intrusive::task_result::resume; }; do { // make sure we have data to read and consume events queue_.synchronized_await(queue_mtx_, queue_cv_); queue_.new_round(1000, f); } while (!stop); log_last_line(); #endif }