您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GNUNET_TIME_relative_multiply函数代码示例

51自学网 2021-06-01 20:53:55
  C++
这篇教程C++ GNUNET_TIME_relative_multiply函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中GNUNET_TIME_relative_multiply函数的典型用法代码示例。如果您正苦于以下问题:C++ GNUNET_TIME_relative_multiply函数的具体用法?C++ GNUNET_TIME_relative_multiply怎么用?C++ GNUNET_TIME_relative_multiply使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了GNUNET_TIME_relative_multiply函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: client_schedule

/** * Function setting up file descriptors and scheduling task to run * * @param  plugin plugin as closure * @param now schedule task in 1ms, regardless of what curl may say * @return GNUNET_SYSERR for hard failure, GNUNET_OK for ok */static intclient_schedule (struct Plugin *plugin, int now){  fd_set rs;  fd_set ws;  fd_set es;  int max;  struct GNUNET_NETWORK_FDSet *grs;  struct GNUNET_NETWORK_FDSet *gws;  long to;  CURLMcode mret;  struct GNUNET_TIME_Relative timeout;  /* Cancel previous scheduled task */  if (plugin->client_perform_task != GNUNET_SCHEDULER_NO_TASK)  {    GNUNET_SCHEDULER_cancel (plugin->client_perform_task);    plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK;  }  max = -1;  FD_ZERO (&rs);  FD_ZERO (&ws);  FD_ZERO (&es);  mret = curl_multi_fdset (plugin->client_mh, &rs, &ws, &es, &max);  if (mret != CURLM_OK)  {    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'/n"),                "curl_multi_fdset", __FILE__, __LINE__,                curl_multi_strerror (mret));    return GNUNET_SYSERR;  }  mret = curl_multi_timeout (plugin->client_mh, &to);  if (to == -1)    timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1);  else    timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, to);  if (now == GNUNET_YES)    timeout = GNUNET_TIME_UNIT_MILLISECONDS;  if (mret != CURLM_OK)  {    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'/n"),                "curl_multi_timeout", __FILE__, __LINE__,                curl_multi_strerror (mret));    return GNUNET_SYSERR;  }  grs = GNUNET_NETWORK_fdset_create ();  gws = GNUNET_NETWORK_fdset_create ();  GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);  GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);  plugin->client_perform_task =      GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,                                   timeout, grs, gws,                                   &client_run, plugin);  GNUNET_NETWORK_fdset_destroy (gws);  GNUNET_NETWORK_fdset_destroy (grs);  return GNUNET_OK;}
开发者ID:h4ck3rm1k3,项目名称:gnunet-debian,代码行数:67,


示例2: test_task

/** * Signature of the main function of a task. * * @param cls closure */static voidtest_task (void *cls){  struct GNUNET_TIME_Absolute now;  now = GNUNET_TIME_absolute_get ();  if (now.abs_value_us > target.abs_value_us)    cumDelta += (now.abs_value_us - target.abs_value_us);  else    cumDelta += (target.abs_value_us - now.abs_value_us);  target =      GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply                                        (GNUNET_TIME_UNIT_MICROSECONDS, i));  FPRINTF (stderr, "%s",  ".");  if (i > MAXV)  {    FPRINTF (stderr, "%s",  "/n");    return;  }  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                (GNUNET_TIME_UNIT_MICROSECONDS, i),				&test_task,                                NULL);  i += INCR;}
开发者ID:GNUnet,项目名称:gnunet,代码行数:30,


示例3: peers_started_callback

static voidpeers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,                        const struct GNUNET_CONFIGURATION_Handle *cfg,                        struct GNUNET_TESTING_Daemon *d, const char *emsg){  if (emsg != NULL)  {    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,                "Failed to start daemon with error: `%s'/n", emsg);    return;  }  GNUNET_assert (id != NULL);  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu/n",              (num_peers - peers_left) + 1, num_peers);#if PROGRESS_BARS  if ((num_peers - peers_left) % modnum == 0)  {    if (num_peers - peers_left == 0)      FPRINTF (stdout, "%s",  "0%%");    else      FPRINTF (stdout, "%d%%",               (int) (((float) (num_peers - peers_left) / num_peers) * 100));  }  else if ((num_peers - peers_left) % dotnum == 0)  {    FPRINTF (stdout, "%s",  ".");  }  fflush (stdout);#endif  peers_left--;  if (peers_left == 0)  {#if PROGRESS_BARS    FPRINTF (stdout, "%s",  "100%%]/n");#endif    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,                "All %d daemons started, now connecting peers!/n", num_peers);    GNUNET_SCHEDULER_cancel (die_task);    /* Set up task in case topology creation doesn't finish     * within a reasonable amount of time */    die_task =        GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                      (GNUNET_TIME_UNIT_MINUTES, 8), &end_badly,                                      "from peers_started_callback");#if DELAY_FOR_LOGGING    FPRINTF (stdout, "%s",  "Connecting topology in 10 seconds/n");    gather_log_data ();    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                  (GNUNET_TIME_UNIT_SECONDS, 10),                                  &connect_topology, NULL);#else    connect_topology ();#endif    ok = 0;  }}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:57,


示例4: send_test_messages

static voidsend_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc){  struct TestMessageContext *pos = cls;  if ((pos == test_messages) && (settle_time.rel_value > 0))  {    topology_connections = 0;    GNUNET_TESTING_get_topology (pg, &topology_cb, NULL);  }  if (((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) || (cls == NULL))    return;  if (die_task == GNUNET_SCHEDULER_NO_TASK)  {    die_task =        GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly,                                      "from send test messages (timeout)");  }  if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS)  {    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                  (GNUNET_TIME_UNIT_SECONDS, 1),                                  &send_test_messages, pos);    return;                     /* Otherwise we'll double schedule messages here! */  }  /*   * Connect to the sending peer   */  pos->peer1handle =      GNUNET_CORE_connect (pos->peer1->cfg, pos, &init_notify_peer1,                           &connect_notify_peers, NULL, NULL, GNUNET_NO, NULL,                           GNUNET_NO, no_handlers);  GNUNET_assert (pos->peer1handle != NULL);  if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS)  {    GNUNET_SCHEDULER_add_now (&send_test_messages, pos->next);  }  else  {    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                  (GNUNET_TIME_UNIT_SECONDS, 1),                                  &send_test_messages, pos->next);  }}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:49,


示例5: run

static voidrun (void *cls,     char *const *args,     const char *cfgfile,     const struct GNUNET_CONFIGURATION_Handle *cfg){  struct GNUNET_MQ_MessageHandler handlers[] = {    GNUNET_MQ_hd_fixed_size (test,                             MTYPE,                             struct GNUNET_MessageHeader,                             NULL),    GNUNET_MQ_handler_end ()  };  GNUNET_assert (ok == 1);  OKPP;  setup_peer (&p1,	      "test_core_api_peer1.conf");  setup_peer (&p2,	      "test_core_api_peer2.conf");  err_task =      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                    (GNUNET_TIME_UNIT_SECONDS, 300),                                    &terminate_task_error, NULL);  p1.ch =      GNUNET_CORE_connect (p1.cfg,			   &p1,                           &init_notify,                           &connect_notify,                           &disconnect_notify,                           handlers);}
开发者ID:GNUnet,项目名称:gnunet,代码行数:32,


示例6: create_topology

static voidcreate_topology (){  peers_left = num_peers;       /* Reset counter */  if (GNUNET_TESTING_create_topology      (pg, topology, blacklist_topology, blacklist_transports) != GNUNET_SYSERR)  {#if PROGRESS_BARS    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,                "Topology set up, now starting peers!/n");    FPRINTF (stdout, "%s",  "Daemon start progress [");#endif    GNUNET_TESTING_daemons_continue_startup (pg);  }  else  {    GNUNET_SCHEDULER_cancel (die_task);    die_task =        GNUNET_SCHEDULER_add_now (&end_badly,                                  "from create topology (bad return)");  }  GNUNET_SCHEDULER_cancel (die_task);  die_task =      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                    (GNUNET_TIME_UNIT_SECONDS,                                     SECONDS_PER_PEER_START * num_peers),                                    &end_badly,                                    "from continue startup (timeout)");}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:29,


示例7: test_master

static voidtest_master (void *cls,	     struct GNUNET_TESTBED_RunHandle *h,	     unsigned int num_peers,	     struct GNUNET_TESTBED_Peer **peers,	     unsigned int links_succeeded,	     unsigned int links_failed){  basic_mqtt_op_publish = GNUNET_TESTBED_service_connect(NULL, /* Closure for operation */							 peers[0], /* The peer whose service to connect to */							 "gnunet-service-mqtt", /* The name of the service */							 service_connect_comp_publish, /* callback to call after a handle to service is opened */							 NULL, /* closure for the above callback */							 gmqtt_ca_publish, /* callback to call with peer's configuration; this should open the needed service connection */							 gmqtt_da_publish, /* callback to be called when closing the opened service connection */							 NULL); /* closure for the above two callbacks */  basic_mqtt_op_subscribe = GNUNET_TESTBED_service_connect(NULL, /* Closure for operation */							   peers[1], /* The peer whose service to connect to */							   "gnunet-service-mqtt", /* The name of the service */							   service_connect_comp_subscribe, /* callback to call after a handle to service is opened */							   NULL, /* closure for the above callback */							   gmqtt_ca_subscribe, /* callback to call with peer's configuration; this should open the needed service connection */							   gmqtt_da_subscribe, /* callback to be called when closing the opened service connection */							   NULL); /* closure for the above two callbacks */			    shutdown_tid = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), 					      &shutdown_task, NULL);}
开发者ID:vsaw,项目名称:gnunet-mqtt,代码行数:28,


示例8: run

/** * Main function that will be run by the scheduler. * * @param cls closure * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */static voidrun (void *cls, char *const *args, const char *cfgfile,     const struct GNUNET_CONFIGURATION_Handle *cfg){  struct GNUNET_TIME_Relative timeout;  if ((NULL == topic))  {    FPRINTF (stderr, "%s",             _("Must provide TOPIC for MQTT SUBSCRIBE!/n"));    ret = 1;    return;  }  mqtt_handle = GNUNET_MQTT_connect (cfg);  if (NULL == mqtt_handle)  {    FPRINTF (stderr, "%s",  _("Failed to connect to MQTT service!/n"));    ret = 1;    return;  }  timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,                                           request_timeout);  GNUNET_MQTT_subscribe (mqtt_handle, strlen(topic) + 1, topic, timeout,                         subscribe_continuation, NULL,                         subscribe_result_callback, NULL);  ret = 0;}
开发者ID:NemoOudeis,项目名称:gnunet-mqtt,代码行数:40,


示例9: run

/** * Initialize framework and start test * * @param cls closure * @param cfg configuration of the peer that was started * @param peer identity of the peer that was created */static voidrun (void *cls,     const struct GNUNET_CONFIGURATION_Handle *cfg,     struct GNUNET_TESTING_Peer *peer){    struct GNUNET_PeerIdentity self;    GNUNET_TESTING_peer_get_identity (peer, &self);    config = cfg;    peer2_listen_socket =        GNUNET_STREAM_listen (config,                              10, /* App port */                              &stream_listen_cb,                              NULL,                              GNUNET_STREAM_OPTION_SIGNAL_LISTEN_SUCCESS,                              &stream_connect,                              GNUNET_STREAM_OPTION_END);    GNUNET_assert (NULL != peer2_listen_socket);    peer1.self = self;    peer2.self = self;    abort_task =        GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                      (GNUNET_TIME_UNIT_SECONDS, 60), &do_abort,                                      NULL);}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:32,


示例10: write_completion

/** * The write completion function; called upon writing some data to stream or * upon error * * @param cls the closure from GNUNET_STREAM_write/read * @param status the status of the stream at the time this function is called * @param size the number of bytes read or written */static voidwrite_completion (void *cls,                  enum GNUNET_STREAM_Status status,                  size_t size){    struct PeerData *peer;    peer = (struct PeerData *) cls;    GNUNET_assert (GNUNET_STREAM_OK == status);    GNUNET_assert (size <= DATA_SIZE);    peer->bytes_wrote += size;    if (peer->bytes_wrote < DATA_SIZE) /* Have more data to send */    {        peer->io_write_handle =            GNUNET_STREAM_write (peer->socket,                                 ((void *) data) + peer->bytes_wrote,                                 sizeof (data) - peer->bytes_wrote,                                 GNUNET_TIME_relative_multiply                                 (GNUNET_TIME_UNIT_SECONDS, 5),                                 &write_completion,                                 cls);        GNUNET_assert (NULL != peer->io_write_handle);    }    else    {        LOG (GNUNET_ERROR_TYPE_DEBUG, "Writing successfully finished/n");        result = GNUNET_OK;        GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);    }}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:39,


示例11: run

/** * Main run function. * * @param cls NULL * @param args arguments passed to GNUNET_PROGRAM_run * @param cfgfile the path to configuration file * @param cfg the configuration file handle */static voidrun (void *cls, char *const *args, const char *cfgfile,     const struct GNUNET_CONFIGURATION_Handle *config){  cfg = GNUNET_CONFIGURATION_dup (config);  host = GNUNET_TESTBED_host_create (NULL, NULL, cfg, 0);  FAIL_TEST (NULL != host);  if (NULL ==      (hc_handle =       GNUNET_TESTBED_is_host_habitable (host, config, &host_habitable_cb,                                         NULL)))  {    GNUNET_TESTBED_host_destroy (host);    GNUNET_CONFIGURATION_destroy (cfg);    cfg = NULL;    host = NULL;    (void) PRINTF ("%s",                   "Unable to run the test as this system is not configured "                   "to use password less SSH logins to localhost./n"                   "Marking test as successful/n");    result = SKIP;    return;  }  abort_task =      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                    (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort,                                    NULL);}
开发者ID:muggenhor,项目名称:GNUnet,代码行数:36,


示例12: peers_started_callback

static voidpeers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,                        const struct GNUNET_CONFIGURATION_Handle *cfg,                        struct GNUNET_TESTING_Daemon *d, const char *emsg){  if (emsg != NULL)  {    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,                "Failed to start daemon with error: `%s'/n", emsg);    return;  }  GNUNET_assert (id != NULL);  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu/n",              (num_peers - peers_left) + 1, num_peers);  peers_left--;  if (peers_left == 0)  {    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,                "All %d daemons started, now testing churn!/n", num_peers);    GNUNET_SCHEDULER_cancel (die_task);    /* Set up task in case topology creation doesn't finish     * within a reasonable amount of time */    die_task =        GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                      (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly,                                      "from peers_started_callback");    churn_peers_off ();    ok = 0;  }}
开发者ID:h4ck3rm1k3,项目名称:gnunet-debian,代码行数:30,


示例13: run_task

static voidrun_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc){  char *fn;  const struct GNUNET_DISK_FileHandle *stdout_read_handle;  const struct GNUNET_DISK_FileHandle *wh;#if !WINDOWS  GNUNET_asprintf (&fn, "cat");#else  GNUNET_asprintf (&fn, "w32cat");#endif  hello_pipe_stdin = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_YES, GNUNET_NO);  hello_pipe_stdout = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES);  if ((hello_pipe_stdout == NULL) || (hello_pipe_stdin == NULL))  {    GNUNET_break (0);    ok = 1;    GNUNET_free (fn);    return;  }  proc =      GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_ERR, hello_pipe_stdin, hello_pipe_stdout, fn,                               "test_gnunet_echo_hello", "-", NULL);  GNUNET_free (fn);  /* Close the write end of the read pipe */  GNUNET_DISK_pipe_close_end (hello_pipe_stdout, GNUNET_DISK_PIPE_END_WRITE);  /* Close the read end of the write pipe */  GNUNET_DISK_pipe_close_end (hello_pipe_stdin, GNUNET_DISK_PIPE_END_READ);  wh = GNUNET_DISK_pipe_handle (hello_pipe_stdin, GNUNET_DISK_PIPE_END_WRITE);  /* Write the test_phrase to the cat process */  if (GNUNET_DISK_file_write (wh, test_phrase, strlen (test_phrase) + 1) !=      strlen (test_phrase) + 1)  {    GNUNET_break (0);    ok = 1;    return;  }  /* Close the write end to end the cycle! */  GNUNET_DISK_pipe_close_end (hello_pipe_stdin, GNUNET_DISK_PIPE_END_WRITE);  stdout_read_handle =      GNUNET_DISK_pipe_handle (hello_pipe_stdout, GNUNET_DISK_PIPE_END_READ);  die_task =      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                    (GNUNET_TIME_UNIT_MINUTES, 1), &end_task,                                    NULL);  GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,                                  stdout_read_handle, &read_call,                                  (void *) stdout_read_handle);}
开发者ID:amatus,项目名称:gnunet-debian,代码行数:60,


示例14: mhd_main

static voidmhd_main (){  struct GNUNET_NETWORK_FDSet nrs;  struct GNUNET_NETWORK_FDSet nws;  fd_set rs;  fd_set ws;  fd_set es;  int max_fd;  unsigned MHD_LONG_LONG timeout;  struct GNUNET_TIME_Relative delay;  GNUNET_assert (NULL == mhd_task_id);  FD_ZERO (&rs);  FD_ZERO (&ws);  FD_ZERO (&es);  max_fd = -1;  GNUNET_assert (MHD_YES == MHD_get_fdset (mhd, &rs, &ws, &es, &max_fd));  if (MHD_YES == MHD_get_timeout (mhd, &timeout))    delay =        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,                                       (unsigned int) timeout);  else    delay = GNUNET_TIME_UNIT_FOREVER_REL;  GNUNET_NETWORK_fdset_copy_native (&nrs, &rs, max_fd + 1);  GNUNET_NETWORK_fdset_copy_native (&nws, &ws, max_fd + 1);  mhd_task_id =      GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, delay,                                   &nrs, &nws, &mhd_task, NULL);}
开发者ID:tg-x,项目名称:gnunet,代码行数:30,


示例15: run

static voidrun (void *cls,     const struct GNUNET_CONFIGURATION_Handle *cfg,     struct GNUNET_TESTING_Peer *peer){  struct GNUNET_HashCode hash;  char *data;  size_t data_size = 42;  GNUNET_assert (ok == 1);  OKPP;  die_task =      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                    (GNUNET_TIME_UNIT_MINUTES, 1), &end_badly,                                    NULL);  memset (&hash, 42, sizeof (struct GNUNET_HashCode));  data = GNUNET_malloc (data_size);  memset (data, 43, data_size);  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_put!/n");  dht_handle = GNUNET_DHT_connect (cfg, 100);  GNUNET_assert (dht_handle != NULL);  GNUNET_DHT_put (dht_handle, &hash, 1, GNUNET_DHT_RO_NONE,                  GNUNET_BLOCK_TYPE_TEST, data_size, data,                  GNUNET_TIME_relative_to_absolute (TOTAL_TIMEOUT),                  &test_get, NULL);  GNUNET_free (data);}
开发者ID:GNUnet,项目名称:gnunet,代码行数:29,


示例16: blacklist_cb

int blacklist_cb (void *cls,                 const struct                 GNUNET_PeerIdentity * pid){  struct PeerContext * p = cls;  int res = GNUNET_SYSERR;  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer  %u : Blacklist request for peer `%s'/n", p->no, GNUNET_i2s (pid));  if (p == p1)  {    blacklist_request_p1 = GNUNET_YES;    res = GNUNET_OK;  }  else if (p == p2)  {    blacklist_request_p2 = GNUNET_YES;    res = GNUNET_SYSERR;  }  if (((blacklist_request_p2 == GNUNET_YES) && (blacklist_request_p1 == GNUNET_YES)) && (shutdown_task == GNUNET_SCHEDULER_NO_TASK))  {    shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3), &end, NULL);  }  return res;}
开发者ID:claudiuolteanu,项目名称:gnunet,代码行数:26,


示例17: stream_write_task

/** * Task for calling STREAM_write with a chunk of random data * * @param cls the peer data entity * @param tc the task context */static voidstream_write_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc){  struct PeerData *pdata = cls;  size_t write_amount;  if (GNUNET_SCHEDULER_NO_TASK != abort_task)  {    GNUNET_SCHEDULER_cancel (abort_task);    abort_task =       GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                    (GNUNET_TIME_UNIT_SECONDS, 300), &do_abort,                                    NULL);  }  write_task = GNUNET_SCHEDULER_NO_TASK;  prof_start_time = GNUNET_TIME_absolute_get ();  pdata->bytes_wrote = 0;  pdata->packets_wrote = 0;  write_amount = MAX_PACKETS * payload_size[payload_size_index];  if (write_amount > DATA_SIZE)    write_amount = DATA_SIZE;  reset_read = GNUNET_YES;  pdata->io_write_handle = GNUNET_STREAM_write (pdata->socket, data,                                                write_amount,						GNUNET_TIME_UNIT_FOREVER_REL,						&write_completion, pdata);  GNUNET_assert (NULL != pdata->io_write_handle);}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:34,


示例18: test_master

/** * Signature of a main function for a testcase. * * @param cls closure * @param h the run handle * @param num_peers number of peers in 'peers' * @param peers_ handle to peers run in the testbed * @param links_succeeded the number of overlay link connection attempts that *          succeeded * @param links_failed the number of overlay link connection attempts that *          failed */static voidtest_master (void *cls,             struct GNUNET_TESTBED_RunHandle *h,             unsigned int num_peers,             struct GNUNET_TESTBED_Peer **peers_,             unsigned int links_succeeded,             unsigned int links_failed){  struct GNUNET_TESTBED_Controller *c;  GNUNET_assert (NULL == cls);  if (NULL == peers_)  {    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failing test due to timeout/n");    return;  }  GNUNET_assert (NUM_PEERS == num_peers);  c = GNUNET_TESTBED_run_get_controller_handle (h);  barrier = GNUNET_TESTBED_barrier_init (c, TEST_BARRIER_NAME, 100,                                         &barrier_cb, NULL);  shutdown_task =      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                    (GNUNET_TIME_UNIT_SECONDS,                                     10 * (NUM_PEERS + 1)),                                    &do_shutdown, NULL);}
开发者ID:muggenhor,项目名称:GNUnet,代码行数:38,


示例19: run_accept

static voidrun_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc){  void *addr;  size_t alen;  struct sockaddr_in *v4;  struct sockaddr_in expect;  asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls);  GNUNET_assert (asock != NULL);  GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock));  GNUNET_assert (GNUNET_OK ==                 GNUNET_CONNECTION_get_address (asock, &addr, &alen));  GNUNET_assert (alen == sizeof (struct sockaddr_in));  v4 = addr;  memset (&expect, 0, sizeof (expect));#if HAVE_SOCKADDR_IN_SIN_LEN  expect.sin_len = sizeof (expect);#endif  expect.sin_family = AF_INET;  expect.sin_port = v4->sin_port;  expect.sin_addr.s_addr = htonl (INADDR_LOOPBACK);  GNUNET_assert (0 == memcmp (&expect, v4, alen));  GNUNET_free (addr);  GNUNET_CONNECTION_destroy (lsock);  GNUNET_CONNECTION_receive (asock, 1024,                             GNUNET_TIME_relative_multiply                             (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check,                             cls);}
开发者ID:claudiuolteanu,项目名称:gnunet-1,代码行数:30,


示例20: run

/** * Main run function. * * @param cls NULL * @param args arguments passed to GNUNET_PROGRAM_run * @param cfgfile the path to configuration file * @param cfg the configuration file handle */static voidrun (void *cls, char *const *args, const char *cfgfile,     const struct GNUNET_CONFIGURATION_Handle *config){  host = GNUNET_TESTBED_host_create (NULL, NULL, 0);  GNUNET_assert (NULL != host);  if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (host, config))  {    GNUNET_TESTBED_host_destroy (host);    host = NULL;    (void) PRINTF ("%s",                   "Unable to run the test as this system is not configured "                   "to use password less SSH logins to localhost./n"                   "Marking test as successful/n");    result = SUCCESS;    return;  }  cfg = GNUNET_CONFIGURATION_dup (config);  cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb,                                        NULL);  abort_task =      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                    (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort,                                    NULL);}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:33,


示例21: receive_check

static voidreceive_check (void *cls, const void *buf, size_t available,               const struct sockaddr *addr, socklen_t addrlen, int errCode){  int *ok = cls;  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive validates incoming data/n");  GNUNET_assert (buf != NULL);  /* no timeout */  if (0 == memcmp (&"Hello World"[sofar], buf, available))    sofar += available;  if (sofar < 12)  {    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive needs more data/n");    GNUNET_CONNECTION_receive (asock, 1024,                               GNUNET_TIME_relative_multiply                               (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check,                               cls);  }  else  {    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive closes accepted socket/n");    *ok = 0;    GNUNET_CONNECTION_destroy (asock);    GNUNET_CONNECTION_destroy (csock);  }}
开发者ID:GNUnet,项目名称:gnunet,代码行数:26,


示例22: task

static voidtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc){  struct sockaddr_in sa;  struct sockaddr *sap[2];  socklen_t slens[2];  sap[0] = (struct sockaddr *) &sa;  slens[0] = sizeof (sa);  sap[1] = NULL;  slens[1] = 0;  memset (&sa, 0, sizeof (sa));#if HAVE_SOCKADDR_IN_SIN_LEN  sa.sin_len = sizeof (sa);#endif  sa.sin_family = AF_INET;  sa.sin_port = htons (PORT);  server =      GNUNET_SERVER_create (NULL, NULL, sap, slens,                            GNUNET_TIME_relative_multiply                            (GNUNET_TIME_UNIT_MILLISECONDS, 250), GNUNET_NO);  GNUNET_assert (server != NULL);  handlers[0].callback_cls = cls;  GNUNET_SERVER_add_handlers (server, handlers);  GNUNET_SERVER_disconnect_notify (server, &notify_disconnect, cls);  cfg = GNUNET_CONFIGURATION_create ();  GNUNET_CONFIGURATION_set_value_number (cfg, "test", "PORT", PORT);  GNUNET_CONFIGURATION_set_value_string (cfg, "test", "HOSTNAME", "localhost");  GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME",                                         "localhost");  client = GNUNET_CLIENT_connect ("test", cfg);  GNUNET_assert (client != NULL);  test_mq (client);}
开发者ID:tg-x,项目名称:gnunet,代码行数:35,


示例23: peer_create_cb

/** * Functions of this signature are called when a peer has been successfully * created * * @param cls the closure from GNUNET_TESTBED_peer_create() * @param peer the handle for the created peer; NULL on any error during *          creation * @param emsg NULL if peer is not NULL; else MAY contain the error description */static voidpeer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg){  GNUNET_assert (NULL != peer);  GNUNET_assert (NULL == emsg);  switch (result)  {  case MASTER_STARTED:    result = MASTER_PEER_CREATE_SUCCESS;    master_peer = peer;    GNUNET_TESTBED_operation_done (op);    op = GNUNET_TESTBED_peer_start (NULL, master_peer, NULL, NULL);    break;  case SLAVE1_LINK_SUCCESS:    result = SLAVE1_PEER_CREATE_SUCCESS;    slave1_peer = peer;    GNUNET_TESTBED_operation_done (op);       op = GNUNET_TESTBED_peer_start (NULL, slave1_peer, NULL, NULL);    break;  case SLAVE2_LINK_SUCCESS:    result = SLAVE2_PEER_CREATE_SUCCESS;    slave2_peer = peer;    GNUNET_TESTBED_operation_done (op);    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                  (GNUNET_TIME_UNIT_SECONDS, 1), &delay_task,                                  NULL);    break;  default:    GNUNET_assert (0);  }  GNUNET_assert (NULL != op);}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:41,


示例24: run

/** * Initialize framework and start test */static voidrun (void *cls, char *const *args, const char *cfgfile,     const struct GNUNET_CONFIGURATION_Handle *cfg){  GNUNET_log_setup ("test_mesh_local",#if VERBOSE                    "DEBUG",#else                    "WARNING",#endif                    NULL);  arm_pid =      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",                               "gnunet-service-arm",#if VERBOSE_ARM                               "-L", "DEBUG",#endif                               "-c", "test_mesh.conf", NULL);  abort_task =      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                    (GNUNET_TIME_UNIT_SECONDS, 20), &do_abort,                                    NULL);  test_task = GNUNET_SCHEDULER_add_now (&test, (void *) cfg);}
开发者ID:h4ck3rm1k3,项目名称:gnunet-debian,代码行数:30,


示例25: test

/** * Main test function */static voidtest (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc){  struct GNUNET_CONFIGURATION_Handle *cfg = cls;  static const GNUNET_MESH_ApplicationType app2[] = { 0 };  test_task = GNUNET_SCHEDULER_NO_TASK;  mesh_peer_2 = GNUNET_MESH_connect (cfg,       /* configuration */                                     10,        /* queue size */                                     (void *) &two,     /* cls */                                     &inbound_tunnel,   /* inbound new hndlr */                                     &inbound_end,      /* inbound end hndlr */                                     handlers2, /* traffic handlers */                                     app2);     /* apps offered */  if (NULL == mesh_peer_2)  {    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "test: Couldn't connect to mesh :(/n");    return;  }  else  {    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: YAY! CONNECTED TO MESH :D/n");  }  t = GNUNET_MESH_tunnel_create (mesh_peer_2, NULL, &peer_conected,                                 &peer_disconnected, (void *) &two);  GNUNET_MESH_peer_request_connect_by_type (t, 1);  test_task =      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                    (GNUNET_TIME_UNIT_SECONDS, 5),                                    &do_connect_peer_1, cfg);}
开发者ID:h4ck3rm1k3,项目名称:gnunet-debian,代码行数:36,


示例26: run

/** * Main function that will be run by the scheduler. * * @param cls closure * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param c configuration */static voidrun (void *cls, char *const *args, const char *cfgfile,     const struct GNUNET_CONFIGURATION_Handle *c){  struct GNUNET_TIME_Relative timeout;  struct GNUNET_TIME_Absolute expiration;  GNUNET_HashCode key;  cfg = c;  if ((query_key == NULL) || (data == NULL))  {    FPRINTF (stderr, "%s",  _("Must provide KEY and DATA for DHT put!/n"));    ret = 1;    return;  }  dht_handle = GNUNET_DHT_connect (cfg, 1);  if (dht_handle == NULL)  {    FPRINTF (stderr, _("Could not connect to %s service!/n"), "DHT");    ret = 1;    return;  }  else if (verbose)    FPRINTF (stderr, _("Connected to %s service!/n"), "DHT");  if (query_type == GNUNET_BLOCK_TYPE_ANY)      /* Type of data not set */    query_type = GNUNET_BLOCK_TYPE_TEST;  GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key);  timeout =      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, timeout_request);  expiration =      GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply                                        (GNUNET_TIME_UNIT_SECONDS,                                         expiration_seconds));  if (verbose)    FPRINTF (stderr, _("Issuing put request for `%s' with data `%s'!/n"),             query_key, data);  GNUNET_DHT_put (dht_handle, &key, replication, GNUNET_DHT_RO_NONE, query_type,                  strlen (data), data, expiration, timeout, &message_sent_cont,                  NULL);}
开发者ID:h4ck3rm1k3,项目名称:gnunet-debian,代码行数:55,


示例27: send_test_messages

static voidsend_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc){  struct TestMessageContext *pos = cls;  if (((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) || (cls == NULL))    return;  if (die_task == GNUNET_SCHEDULER_NO_TASK)  {    die_task =        GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly,                                      "from create topology (timeout)");  }  if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS)  {    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                  (GNUNET_TIME_UNIT_SECONDS, 1),                                  &send_test_messages, pos);    return;                     /* Otherwise we'll double schedule messages here! */  }  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,              "Attempting to send test message from %s to %s/n",              pos->peer1->shortname, pos->peer2->shortname);  /*   * Connect to the sending peer   */  pos->peer1handle =      GNUNET_CORE_connect (pos->peer1->cfg, pos, &init_notify_peer1,                           &connect_notify_peer1, NULL, NULL, GNUNET_NO, NULL,                           GNUNET_NO, no_handlers);  GNUNET_assert (pos->peer1handle != NULL);  if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS)  {    GNUNET_SCHEDULER_add_now (&send_test_messages, pos->next);  }  else  {    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply                                  (GNUNET_TIME_UNIT_SECONDS, 1),                                  &send_test_messages, pos->next);  }}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:46,


示例28: short_wait

/** * Wait for a short time (we're trying to lock a file or want * to give another process a shot at finishing a disk write, etc.). * Sleeps for 100ms (as that should be long enough for virtually all * modern systems to context switch and allow another process to do * some 'real' work). */static voidshort_wait (){  struct GNUNET_TIME_Relative timeout;  timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100);  (void) GNUNET_NETWORK_socket_select (NULL, NULL, NULL, timeout);}
开发者ID:muggenhor,项目名称:GNUnet,代码行数:15,


示例29: task

static voidtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc){    struct sockaddr_un un;    const char *unixpath = "/tmp/testsock";    size_t slen = strlen (unixpath);    struct sockaddr *sap[2];    socklen_t slens[2];    memset (&un, 0, sizeof (un));    un.sun_family = AF_UNIX;    memcpy (un.sun_path, unixpath, slen);    un.sun_path[slen] = '/0';#if HAVE_SOCKADDR_IN_SIN_LEN    un.sun_len = (u_char) sizeof (un);#endif#if LINUX    un.sun_path[0] = '/0';#endif    sap[0] = (struct sockaddr *) &un;    slens[0] = sizeof (un);    sap[1] = NULL;    slens[1] = 0;    server =        GNUNET_SERVER_create (NULL, NULL, sap, slens,                              GNUNET_TIME_relative_multiply                              (GNUNET_TIME_UNIT_MILLISECONDS, 250), GNUNET_NO);    GNUNET_assert (server != NULL);    handlers[0].callback_cls = cls;    GNUNET_SERVER_add_handlers (server, handlers);    GNUNET_SERVER_disconnect_notify (server, &notify_disconnect, cls);    cfg = GNUNET_CONFIGURATION_create ();    GNUNET_CONFIGURATION_set_value_string (cfg, "test", "UNIXPATH", unixpath);    GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME",                                           "localhost");    client = GNUNET_CLIENT_connect ("test", cfg);    GNUNET_assert (client != NULL);    GNUNET_CLIENT_notify_transmit_ready (client, 256,                                         GNUNET_TIME_relative_multiply                                         (GNUNET_TIME_UNIT_MILLISECONDS, 250),                                         GNUNET_NO, &notify_ready, NULL);}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:45,


示例30: start_helper

/** * Start the helper process. * * @param h handle to the helper process */static voidstart_helper (struct GNUNET_HELPER_Handle *h){  h->helper_in = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_YES, GNUNET_NO);  h->helper_out = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES);  if ( (h->helper_in == NULL) || (h->helper_out == NULL))  {    /* out of file descriptors? try again later... */    stop_helper (h, GNUNET_NO);    h->restart_task =      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,								  h->retry_back_off),				    &restart_task, h);    return;  }  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,	      "Starting HELPER process `%s'/n",	      h->binary_name);  h->fh_from_helper =      GNUNET_DISK_pipe_handle (h->helper_out, GNUNET_DISK_PIPE_END_READ);  h->fh_to_helper =      GNUNET_DISK_pipe_handle (h->helper_in, GNUNET_DISK_PIPE_END_WRITE);  h->helper_proc =    GNUNET_OS_start_process_vap (h->with_control_pipe, GNUNET_OS_INHERIT_STD_ERR,				 h->helper_in, h->helper_out, NULL,				 h->binary_name,				 h->binary_argv);  if (NULL == h->helper_proc)  {    /* failed to start process? try again later... */    stop_helper (h, GNUNET_NO);    h->restart_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,										  h->retry_back_off),						    &restart_task, h);    return;  }  GNUNET_DISK_pipe_close_end (h->helper_out, GNUNET_DISK_PIPE_END_WRITE);  GNUNET_DISK_pipe_close_end (h->helper_in, GNUNET_DISK_PIPE_END_READ);  if (NULL != h->mst)    h->read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,						   h->fh_from_helper,						   &helper_read,						   h);}
开发者ID:GNUnet,项目名称:gnunet,代码行数:49,



注:本文中的GNUNET_TIME_relative_multiply函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ GNUNET_TIME_relative_to_absolute函数代码示例
C++ GNUNET_TIME_absolute_get_remaining函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。