这篇教程C++ time_now函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中time_now函数的典型用法代码示例。如果您正苦于以下问题:C++ time_now函数的具体用法?C++ time_now怎么用?C++ time_now使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了time_now函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: perftt_nodes perft(struct t_board *board, int depth) { struct t_move_list move_list[1]; struct t_undo undo[1]; t_nodes total_nodes = 0; t_nodes move_nodes = 0; unsigned long start = time_now(); int i; if (board->in_check) generate_evade_check(board, move_list); else generate_moves(board, move_list); for (i = move_list->count - 1; i >= 0; i--) { if (make_move(board, move_list->pinned_pieces, move_list->move[i], undo)) { move_nodes = 0; if (depth > 1) move_nodes += do_perft(board, depth - 1); printf(move_as_str(move_list->move[i])); printf(" = %u/n", move_nodes); unmake_move(board, undo); total_nodes += move_nodes; } } unsigned long finish = time_now(); if (finish == start) printf("Total Nodes: %I64d/n", total_nodes); else printf("Total Nodes: %I64d in %d milliseconds = nps %I64d/n", total_nodes, finish - start, 1000 * total_nodes / (finish - start)); return total_nodes;}
开发者ID:stevemaughan,项目名称:maverick,代码行数:38,
示例2: msg void GroupNodeImpl::handle_whisper(const std::string& uuid, zmsg_t* zmsg) { MessagePtr msg(new Message); msg->header.stamp = time_now(); msg->header.context = uuid; msg->header.src_uuid = uuid; char* a_str = zmsg_popstr(zmsg); msg->msg = a_str; free(a_str); auto range = whisper_handlers_.equal_range("w"); std::for_each(range.first, range.second, [&](handlers_t::value_type& c){c.second.first(msg.get(), c.second.second);}); }
开发者ID:mikegulf,项目名称:quickmsg,代码行数:14,
示例3: time_now // returns true if our external IP changed bool ip_voter::maybe_rotate() { ptime now = time_now(); // if we have more than or equal to 50 votes, // we rotate. Also, if it's been more than 5 minutes // and we have at least one vote, we also rotate. // this is the inverse condition, since this is the case // were we exit, without rotating if (m_total_votes < 50 && (now - m_last_rotate < minutes(5) || m_total_votes == 0) && m_valid_external) return false; // this shouldn't really happen if we have at least one // vote. if (m_external_addresses.empty()) return false; // if there's just one vote, go with that std::vector<external_ip_t>::iterator i; if (m_external_addresses.size() == 1) { // avoid flapping. We need more votes to change our mind on the // external IP if (m_external_addresses[0].num_votes < 2) return false; } else { // find the top two votes. std::partial_sort(m_external_addresses.begin() , m_external_addresses.begin() + 2, m_external_addresses.end()); // if we don't have enough of a majority voting for the winning // IP, don't rotate. This avoids flapping if (m_external_addresses[0].num_votes * 2 / 3 <= m_external_addresses[1].num_votes) return false; } i = m_external_addresses.begin(); bool ret = m_external_address != i->addr; m_external_address = i->addr; m_external_address_voters.clear(); m_total_votes = 0; m_external_addresses.clear(); m_last_rotate = now; m_valid_external = true; return ret; }
开发者ID:EricMyers47,项目名称:OpenSpace,代码行数:51,
示例4: attempt_failed_tokstatic struct command_result *waitsendpay_error(struct command *cmd, const char *buf, const jsmntok_t *error, struct pay_command *pc){ const jsmntok_t *codetok, *scidtok, *dirtok; int code; attempt_failed_tok(pc, "waitsendpay", buf, error); codetok = json_get_member(buf, error, "code"); if (!json_to_int(buf, codetok, &code)) plugin_err("waitsendpay error gave no 'code'? '%.*s'", error->end - error->start, buf + error->start); /* FIXME: Handle PAY_UNPARSEABLE_ONION! */ /* Many error codes are final. */ if (code != PAY_TRY_OTHER_ROUTE) { return forward_error(cmd, buf, error, pc); } scidtok = json_delve(buf, error, ".data.erring_channel"); if (!scidtok) plugin_err("waitsendpay error no erring_channel '%.*s'", error->end - error->start, buf + error->start); dirtok = json_delve(buf, error, ".data.erring_direction"); if (!dirtok) plugin_err("waitsendpay error no erring_direction '%.*s'", error->end - error->start, buf + error->start); if (time_after(time_now(), pc->stoptime)) { return waitsendpay_expired(cmd, pc); } /* If failure is in routehint part, try next one */ if (channel_in_routehint(pc->current_routehint, buf, scidtok)) return next_routehint(cmd, pc); /* Otherwise, add erring channel to exclusion list. */ tal_arr_expand(&pc->excludes, tal_fmt(pc->excludes, "%.*s/%c", scidtok->end - scidtok->start, buf + scidtok->start, buf[dirtok->start])); /* Try again. */ return start_pay_attempt(cmd, pc, "Excluded channel %s", pc->excludes[tal_count(pc->excludes)-1]);}
开发者ID:cdecker,项目名称:lightning,代码行数:49,
示例5: write_body_headerMODULE write_body_header (THREAD *thread){ tcb = thread-> tcb; /* Point to thread's context */ smtp_msg = tcb-> message; /* only for readability */ *strout = '/0'; /* clears out buffer */ /* Set the date and time of the message. */ xstrcat ( strout, "Date: ", encode_mime_time (date_now (), time_now ()), " /r/n", NULL); replacechrswith (smtp_msg-> dest_uids, ";", ','); xstrcat (strout, "To: ", smtp_msg-> dest_uids, "/r/n", NULL); if ( strstr( smtp_msg-> sender_uid, "<" ) != NULL && strstr( smtp_msg-> sender_uid, ">" ) != NULL ) xstrcat (strout, "Reply-To:", smtp_msg-> sender_uid, "/r/n", NULL); else xstrcat (strout, "Reply-To:<", smtp_msg-> sender_uid, ">/r/n", NULL); xstrcat (strout, "Sender:", smtp_msg-> sender_uid, "/r/n", NULL); xstrcat (strout, "From:", smtp_msg-> sender_uid, "/r/n", NULL); xstrcat (strout, "X-Mailer: sflmail function/r/n", NULL); /* Set the mime version. */ xstrcat (strout, "MIME-Version: 1.0/r/n", "Content-Type: Multipart/Mixed; boundary=/"", tcb-> message_boundary, "/"/r/n", NULL); /* Send the subject and message body. */ ASSERT (smtp_msg-> subject != NULL); /* XXX I'm not too sure */ xstrcat (strout, "Subject:", smtp_msg-> subject, "/r/n/r/n", NULL); /* Send the plain text body header */ xstrcat (strout, tcb-> plain_text_body_header, NULL); send_smtsock_write( &sockq, 0, /* Timeout in seconds, zero = none */ tcb-> sock_handle, /* Socket to write to */ (word) strlen (strout), /* Amount of data to write */ strout, /* Block of data to write */ FALSE, /* Whether to always reply */ (void *) SOCK_TAG_WRITE); /* User-defined request tag */ TRACE_SMTP (strout);}
开发者ID:INNOAUS,项目名称:gsl,代码行数:49,
示例6: time_now void timeout_handler::set_timeout(int completion_timeout, int read_timeout) { m_completion_timeout = completion_timeout; m_read_timeout = read_timeout; m_start_time = m_read_time = time_now(); if (m_abort) return; int timeout = (std::min)( m_read_timeout, (std::min)(m_completion_timeout, m_read_timeout)); error_code ec; m_timeout.expires_at(m_read_time + seconds(timeout), ec); m_timeout.async_wait(bind( &timeout_handler::timeout_callback, self(), _1)); }
开发者ID:Krinkelss,项目名称:libtorrent,代码行数:15,
示例7: tmr_adjust/** @brief adjust the time when a timer expires */int tmr_adjust(tmr_t *timer, tmr_time_t t, uint32_t param, tmr_time_t r){ int i; for (i = 0; i < ti; i++) if (timer == timers[i]) break; if (i >= ti) return -1; timer->expire = time_now() + t; timer->restart = r; timer->param = param; cycles = z80_cc; return 0;}
开发者ID:schnitzeltony,项目名称:z80,代码行数:16,
示例8: m_queued_bytes bandwidth_manager::bandwidth_manager(int channel#ifdef TORRENT_VERBOSE_BANDWIDTH_LIMIT , bool log = false#endif ) : m_queued_bytes(0) , m_channel(channel) , m_abort(false) {#ifdef TORRENT_VERBOSE_BANDWIDTH_LIMIT if (log) m_log.open("bandwidth_limiter.log", std::ios::trunc); m_start = time_now();#endif }
开发者ID:Chaduke,项目名称:bah.mod,代码行数:15,
示例9: set_alarm/** * Inspect head of queue and wakeup a worker now or set alarm. * Caller SHOULD hold schedule->schedule_lock. Failing to do so * could possibly cause a thread to miss the wakeup. */static voidset_alarm(schedule_type* schedule){ time_t now = time_now(); task_type *task = get_first_task(schedule); if (!task || task->when == -1) { ods_log_debug("[%s] no alarm set", schedule_str); } else if (task->when == 0 || task->when <= now) { ods_log_debug("[%s] signal now", schedule_str); pthread_cond_signal(&schedule->schedule_cond); } else { ods_log_debug("[%s] SIGALRM set", schedule_str); alarm(task->when - now); }}
开发者ID:eest,项目名称:opendnssec,代码行数:20,
示例10: Timer_setTimer * Timer_set(double delay, TimerFn *fn, unsigned long data) { // Get 'now'. double now = time_now(); Timer *timer = NULL; timer = ALLOCATE(Timer); if(!timer) goto exit; // Add delay to now to get expiry time. timer->expiry = now + delay; timer->fn = fn; timer->data = data; Timer_add(timer);exit: return timer;}
开发者ID:mikesun,项目名称:xen-cow-checkpointing,代码行数:15,
示例11: do_log_debugvoid do_log_debug(const char *file, int line, char *format, ...) { va_list ap; va_start(ap, format); char *timestamp = time_now(); char new_format[strlen(timestamp) + strlen(format) + strlen(file) + 5 + // (reasonable length for 'line') 6 + // space for PID + 23]; sprintf(new_format, "[%d] [%s] [DEBUG] %s:%d: %s/n", getpid(), timestamp, file, line, format); vfprintf(RS_LOG_FILE, new_format, ap); va_end(ap); fflush(RS_LOG_FILE);}
开发者ID:KansasLinuxFest,项目名称:rs-serve,代码行数:15,
示例12: calloc/** @brief allocate a new timer */tmr_t *tmr_alloc(void (*callback)(uint32_t), tmr_time_t t, uint32_t param, tmr_time_t r){ tmr_t *timer; if (ti >= MAX_TMR) return NULL; timers[ti] = timer = calloc(1, sizeof(tmr_t)); if (NULL == timer) return NULL; ti++; timer->expire = time_now() + t; timer->restart = r; timer->param = param; timer->callback = callback; cycles = z80_cc; return timer;}
开发者ID:schnitzeltony,项目名称:z80,代码行数:17,
示例13: udp_readcbvoid udp_readcb(struct bufferevent *bev, void *c) { UNUSED(c); char buf[3] = {0}; struct evbuffer *input = bufferevent_get_input(bev); while (evbuffer_get_length(input) >= 3) { bufferevent_read(bev, buf, 3); if (!strncmp(buf, "ACK", 3)) { udp_last_ack = time_now(); if (!connection_valid) { connection_valid = true; log_notice("Connected to %s", config_get_remote_hostname()); } } } return;}
开发者ID:JayconSystems,项目名称:c3listener,代码行数:16,
示例14: dp_runvoiddp_run(struct datapath *dp) { time_t now = time_now(); struct remote *r, *rn; size_t i; if (now != dp->last_timeout) { dp->last_timeout = now; meter_table_add_tokens(dp->meters); pipeline_timeout(dp->pipeline); } poll_timer_wait(1000); dp_ports_run(dp); /* Talk to remotes. */ LIST_FOR_EACH_SAFE (r, rn, struct remote, node, &dp->remotes) { remote_run(dp, r); } for (i = 0; i < dp->n_listeners; ) { struct pvconn *pvconn = dp->listeners[i]; struct vconn *new_vconn; int retval = pvconn_accept(pvconn, OFP_VERSION, &new_vconn); if (!retval) { struct rconn * rconn_aux = NULL; if (dp->n_listeners_aux && dp->listeners_aux[i] != NULL) { struct pvconn *pvconn_aux = dp->listeners_aux[i]; struct vconn *new_vconn_aux; int retval_aux = pvconn_accept(pvconn_aux, OFP_VERSION, &new_vconn_aux); if (!retval_aux) rconn_aux = rconn_new_from_vconn("passive_aux", new_vconn_aux); } remote_create(dp, rconn_new_from_vconn("passive", new_vconn), rconn_aux); } else if (retval != EAGAIN) { VLOG_WARN_RL(LOG_MODULE, &rl, "accept failed (%s)", strerror(retval)); dp->listeners[i] = dp->listeners[--dp->n_listeners]; if (dp->n_listeners_aux) { dp->listeners_aux[i] = dp->listeners_aux[--dp->n_listeners_aux]; } continue; } i++; }}
开发者ID:BiangHoo,项目名称:ofsoftswitch13,代码行数:47,
示例15: tcp_wait_for_eventsstatic int tcp_wait_for_events(tcp_context_t *tcp){ /* Wait for events. */ fdset_t *set = &tcp->set; int nfds = poll(set->pfd, set->n, TCP_SWEEP_INTERVAL * 1000); /* Mark the time of last poll call. */ time_now(&tcp->last_poll_time); /* Process events. */ unsigned i = 0; while (nfds > 0 && i < set->n) { /* Terminate faulty connections. */ int fd = set->pfd[i].fd; /* Active sockets. */ if (set->pfd[i].revents & POLLIN) { --nfds; /* One less active event. */ /* Indexes <0, client_threshold) are master sockets. */ if (i < tcp->client_threshold) { /* Faulty master sockets shall be sorted later. */ (void) tcp_event_accept(tcp, i); } else { if (tcp_event_serve(tcp, i) != KNOT_EOK) { fdset_remove(set, i); close(fd); continue; /* Stay on the same index. */ } } } if (set->pfd[i].revents & (POLLERR|POLLHUP|POLLNVAL)) { --nfds; /* One less active event. */ fdset_remove(set, i); close(fd); continue; /* Stay on the same index. */ } /* Next socket. */ ++i; } return nfds;}
开发者ID:jkadlec,项目名称:knot-dns-zoneapi,代码行数:47,
示例16: tmr_reset/** @brief reset the time when a timer expires */int tmr_reset(tmr_t *timer, tmr_time_t t){ int i; for (i = 0; i < ti; i++) if (timer == timers[i]) break; if (i >= ti) return -1; if (time_never == t) { timer->expire = time_never; } else { timer->expire = time_now() + t; } cycles = z80_cc; return 0;}
开发者ID:schnitzeltony,项目名称:z80,代码行数:18,
示例17: conf_dbg_dump/***************************************************************************** 函 数 名 : conf_dbg_dump 功能描述 : dump数据块的数据 参数列表 : const void *buffer int buf_len 返 回 值 : void*****************************************************************************/void conf_dbg_dump(const void *buffer, int buf_len){ int i; u8_t *ptr; char str[17] = {0}; FILE *out; asc_time_t now; if ((dbg_level < DBG_DEBUG) || (buf_len == 0)) { return; } out = (log_file != NULL) ? log_file : stderr; pthread_mutex_lock(&out_mutex); fprintf(out, "%s [DEBUG] Buffer length is %d./n", time_now(&now), buf_len); for (i = 0, ptr = (u8_t*)buffer; (i < buf_len) || ((i & 0xf) != 0); ++i) { if ((i & 0xf) == 0) { fprintf(out, " [%04d]", i); } else if ((i & 0x7) == 0) { fprintf(out, " "); } if (i < buf_len) { fprintf(out, " %02x", (u8_t)(ptr[i])); if ((0x20 <= ptr[i]) && (ptr[i] <= 0x7e)) { str[i & 0xf] = ptr[i]; } else { str[i & 0xf] = '.'; } } else { fprintf(out, " "); str[i & 0xf] = 0; } if ((i & 0xf) == 0xf) { fprintf(out, " | %s/n", str); } } pthread_mutex_unlock(&out_mutex); return;}
开发者ID:daixinning,项目名称:oxygen,代码行数:53,
示例18: enforce_tasktask_type *enforce_task(engine_type *engine, bool all){ task_id what_id; const char *what = "enforce"; const char *who = "next zone"; struct enf_task_ctx *ctx = &enforcer_context; if (!ctx) { ods_log_error("Malloc failure, enforce task not scheduled"); return NULL; } ctx->engine = engine; ctx->enforce_all = all; what_id = task_register(what, module_str, enforce_task_perform); return task_create(what_id, time_now(), who, what, ctx, enforce_task_clean_ctx);}
开发者ID:eest,项目名称:opendnssec,代码行数:17,
示例19: fail_open_startvoidfail_open_start(struct secchan *secchan, const struct settings *s, struct switch_status *ss, struct rconn *local_rconn, struct rconn *remote_rconn){ struct fail_open_data *fail_open = xmalloc(sizeof *fail_open); fail_open->s = s; fail_open->local_rconn = local_rconn; fail_open->remote_rconn = remote_rconn; fail_open->lswitch = NULL; fail_open->boot_deadline = time_now() + s->probe_interval * 3; if (s->enable_stp) { fail_open->boot_deadline += STP_EXTRA_BOOT_TIME; } switch_status_register_category(ss, "fail-open", fail_open_status_cb, fail_open); add_hook(secchan, &fail_open_hook_class, fail_open);}
开发者ID:TakashiSasaki,项目名称:openflow,代码行数:18,
示例20: cevents_poll//return push queue count or J_ERRint cevents_poll(cevents *cevts, msec_t ms) { int rs, i, count = 0, flag = 0; cevent_fired *fired; cevent *evt; if(cevts == NULL) { ERROR("can't be happend/n"); abort(); } LOCK(&cevts->lock); rs = cevents_poll_impl(cevts, ms); UNLOCK(&cevts->lock); time_now(&cevts->poll_sec, &cevts->poll_ms); if(rs > 0) { for(i = 0; i < rs; i++) { fired = cevts->fired + i; evt = cevts->events + fired->fd; if(!evt->mask) continue; if(evt->mask & CEV_PERSIST) { fired->mask |= CEV_PERSIST; if(evt->mask && (fired->mask & CEV_READ)) { //just send read event to event queue. if(evt->read_proc(cevts, fired->fd, evt->priv, fired->mask) == 0) { cevents_del_event(cevts, fired->fd, CEV_READ); cevents_push_fired(cevts, clone_cevent_fired(cevts, fired)); count++; } } if(evt->mask && (fired->mask & CEV_WRITE)) { evt->write_proc(cevts, fired->fd, evt->priv, fired->mask); } } else { //unbind the events. cevents_del_event(cevts, fired->fd, fired->mask); cevents_push_fired(cevts, clone_cevent_fired(cevts, fired)); count++; } } } //must sleep, let other thread grant the lock. maybe removed when the time event added. usleep(2); return count;}
开发者ID:Joinhack,项目名称:thr_socket,代码行数:45,
示例21: age_flow_entriesstatic voidage_flow_entries( void *user_data ) { const uint8_t table_id = *( uint8_t * ) user_data; assert( valid_table_id( table_id ) ); if ( !lock_pipeline() ) { return; } struct timespec now = { 0, 0 }; time_now( &now ); foreach_flow_entry( table_id, age_flow_entries_walker, &now ); if ( !unlock_pipeline() ) { return; }}
开发者ID:kazuyas,项目名称:trema-edge,代码行数:19,
示例22: test_time_whmsstatic void test_time_whms(void){ a_time t_ = time_clone(time_now()), *t = &t_;#define X(wday, hour, min, sec) do { / time_whms(t, wday, hour, min, sec); / time_t time = time_time(t); / a_time t2; / time_init(&t2, time); / const struct tm *tm = time_tm(&t2); / if (tm->tm_wday != wday) TFAILF(" %s", "wday mismatch"); / if (tm->tm_sec != sec) TFAILF(" sec %d vs %d", tm->tm_sec, sec); / if (tm->tm_min != min) TFAILF(" min %d vs %d", tm->tm_min, min); / if (tm->tm_hour != hour) TFAILF(" hour %d vs %d", tm->tm_hour, hour); / } while_0 X(0, 0, 0, 0); X(1, 1, 1, 1); X(6, 23, 59, 59);#undef X}
开发者ID:plujon,项目名称:hrs3-c,代码行数:19,
示例23: logline/* Write the time, client address, prefix, and string s to stderr atomically. * s should end with a /n */voidlogline(struct in_addr *client, char *prefix, char *s){ double now = time_now(); char addr[INET_ADDRSTRLEN]; if (client) {#ifdef _WIN32 strcpy(addr, inet_ntoa(*client));#else inet_ntop(AF_INET, client, addr, sizeof(addr));#endif } else { addr[0] = '/0'; } pthread_mutex_lock(&log_lock); fprintf(stderr, "%s%15s %9.3f: %s", prefix, addr, now - start_time, s); pthread_mutex_unlock(&log_lock);}
开发者ID:Daimas,项目名称:android-pachi,代码行数:21,
示例24: fileop_save_by_nameint fileop_save_by_name( char *file_name ){ FILE *fp; char name[ MAX_TOKEN_LENGTH ]; char s[80]; strcpy( name, file_name ); file_handle_path( name, MAX_TOKEN_LENGTH ); if ( NULL == (fp = fopen( name, "w" )) ) { cprintf( ERROR, CONT, "fail to save file /"%s/"/n", name ); return ( ERROR ); } fprintf( fp, "###/n" ); fprintf( fp, "### CaFE file made by /"save/" command./n" ); fprintf( fp, "### --- %s ---/n", version_string( s ) ); time_now( s ); fprintf( fp, "###/n### ### saved : %s/n###/n", s ); fprintf( fp, "/n/n### user stack operation functions/n/n" ); fprintf( fp, "0 >newlydefined_{/n" ); fprintf( fp, "0 >newlydefined_k}/n/n" ); fprintf( fp, "fisdef { if z :@ :{ =new =target ; 1 >newlydefined_{ ; pop/n/n" ); fprintf( fp, "fisdef k} if z :@ :k} =parent =target ; 1 >newlydefined_k} ; pop/n/n/n" ); fprintf( fp, "### content of stack/n/n" ); save_stack( NULL, fp ); fprintf( fp, "/n/n### content of stack end/n/n" ); fprintf( fp, "<newlydefined_{ if t :@ forget { ; pop/n" ); fprintf( fp, "<newlydefined_k} if t :@ forget k} ; pop/n" ); fclose( fp ); return ( NO_ERROR );}
开发者ID:teddokano,项目名称:CaFE2,代码行数:43,
示例25: itimer_set/** Set the process real-time timer to go off at a given expiry time. * The timer will not be set to go off in less than 10 ms * (even if the expiry time is sooner, or in the past). * * @param expiry time (in seconds) * @return 0 on success, error code otherwise */static int itimer_set(double expiry) { struct itimerval val = {}; struct itimerval old = {}; double now, delay; int err = 0; if(expiry == 0.0) { val.it_value.tv_sec = 0; val.it_value.tv_usec = 0; } else { now = time_now(); delay = expiry - now; if(delay < 0.01) delay = 0.01; val.it_value.tv_sec = (long)delay; val.it_value.tv_usec = (long)((delay - (double)(long)delay) * 1.0e6); } err = setitimer(ITIMER_REAL, &val, &old); return err;}
开发者ID:mikesun,项目名称:xen-cow-checkpointing,代码行数:26,
示例26: schedule_pop_tasktask_type*schedule_pop_task(schedule_type* schedule){ time_t now = time_now(); task_type* task; pthread_mutex_lock(&schedule->schedule_lock); task = get_first_task(schedule); if (!task || (!task->flush && (task->when == -1 || task->when > now))) { /* nothing to do now, sleep and wait for signal */ pthread_cond_wait(&schedule->schedule_cond, &schedule->schedule_lock); task = NULL; } else { task = pop_first_task(schedule); } pthread_mutex_unlock(&schedule->schedule_lock); return task;}
开发者ID:eest,项目名称:opendnssec,代码行数:19,
示例27: schedule_flush_typeintschedule_flush_type(schedule_type* schedule, task_id id){ ldns_rbnode_t *node, *nextnode; int nflushed = 0; ods_log_debug("[%s] flush task", schedule_str); if (!schedule || !schedule->tasks) return 0; pthread_mutex_lock(&schedule->schedule_lock); node = ldns_rbtree_first(schedule->tasks); while (node && node != LDNS_RBTREE_NULL) { nextnode = ldns_rbtree_next(node); if (node->data && ((task_type*)node->data)->what == id) { /* Merely setting flush is not enough. We must set it * to the front of the queue as well. */ node = ldns_rbtree_delete(schedule->tasks, node->data); if (!node) break; /* stange, bail out */ if (node->data) { /* task */ ((task_type*)node->data)->flush = 1; /* This is important for our tests only. If a task is * set to flush it should not affect the current time. * Otherwise timeleap will advance time. */ ((task_type*)node->data)->when = time_now(); if (!ldns_rbtree_insert(schedule->tasks, node)) { ods_log_crit("[%s] Could not reschedule task " "after flush. A task has been lost!", schedule_str); free(node); /* Do not free node->data it is still in use * by the other rbtree. */ break; } nflushed++; } } node = nextnode; } /* wakeup! work to do! */ pthread_cond_signal(&schedule->schedule_cond); pthread_mutex_unlock(&schedule->schedule_lock); return nflushed;}
开发者ID:eest,项目名称:opendnssec,代码行数:43,
注:本文中的time_now函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ time_now_d函数代码示例 C++ time_msec函数代码示例 |