当前位置: 首页>>代码示例>>C++>>正文


C++ drain_cq函数代码示例

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


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

示例1: end_test

static void end_test(grpc_end2end_test_fixture *f) {
  shutdown_server(f);
  shutdown_client(f);

  grpc_completion_queue_shutdown(f->server_cq);
  drain_cq(f->server_cq);
  grpc_completion_queue_destroy(f->server_cq);
  grpc_completion_queue_shutdown(f->client_cq);
  drain_cq(f->client_cq);
  grpc_completion_queue_destroy(f->client_cq);
}
开发者ID:LonelyPale,项目名称:grpc,代码行数:11,代码来源:invoke_large_request.c

示例2: teardown_servers

static void teardown_servers(servers_fixture *f) {
  size_t i;
  /* Destroy server. */
  for (i = 0; i < f->num_servers; i++) {
    if (f->servers[i] == NULL) continue;
    grpc_server_shutdown_and_notify(f->servers[i], f->cq, tag(10000));
    GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(10000),
                                           n_millis_time(5000), NULL)
                   .type == GRPC_OP_COMPLETE);
    grpc_server_destroy(f->servers[i]);
  }
  grpc_completion_queue_shutdown(f->cq);
  drain_cq(f->cq);
  grpc_completion_queue_destroy(f->cq);

  gpr_free(f->servers);

  for (i = 0; i < f->num_servers; i++) {
    gpr_free(f->servers_hostports[i]);
    grpc_metadata_array_destroy(&f->request_metadata_recv[i]);
  }

  gpr_free(f->servers_hostports);
  gpr_free(f->request_metadata_recv);
  gpr_free(f->server_calls);
  gpr_free(f);
}
开发者ID:cj525,项目名称:grpc,代码行数:27,代码来源:lb_policies_test.c

示例3: end_test

static void end_test(grpc_end2end_test_fixture *f) {
  shutdown_client(f);

  grpc_completion_queue_shutdown(f->cq);
  drain_cq(f->cq);
  grpc_completion_queue_destroy(f->cq);
  /* f->shutdown_cq is not used in this test */
  grpc_completion_queue_destroy(f->shutdown_cq);
}
开发者ID:aaronjheng,项目名称:grpc,代码行数:9,代码来源:shutdown_finishes_tags.c

示例4: test_connect


//.........这里部分代码省略.........
  gpr_log(GPR_INFO, "Testing with server=%s client=%s (expecting %s)",
          server_hostport, client_hostport, expect_ok ? "success" : "failure");

  gpr_free(client_hostport);
  gpr_free(server_hostport);

  if (expect_ok) {
    /* Normal deadline, shouldn't be reached. */
    deadline = ms_from_now(60000);
  } else {
    /* Give up faster when failure is expected.
       BUG: Setting this to 1000 reveals a memory leak (b/18608927). */
    deadline = ms_from_now(1500);
  }

  /* Send a trivial request. */
  c = grpc_channel_create_call(client, client_cq, "/foo", "foo.test.google.fr",
                               deadline);
  GPR_ASSERT(c);

  op = ops;
  op->op = GRPC_OP_SEND_INITIAL_METADATA;
  op->data.send_initial_metadata.count = 0;
  op++;
  op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
  op++;
  op->op = GRPC_OP_RECV_INITIAL_METADATA;
  op->data.recv_initial_metadata = &initial_metadata_recv;
  op++;
  op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
  op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
  op->data.recv_status_on_client.status = &status;
  op->data.recv_status_on_client.status_details = &details;
  op->data.recv_status_on_client.status_details_capacity = &details_capacity;
  op++;
  GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));

  if (expect_ok) {
    /* Check for a successful request. */
    GPR_ASSERT(GRPC_CALL_OK ==
               grpc_server_request_call(server, &s, &call_details,
                                        &request_metadata_recv, server_cq,
                                        server_cq, tag(101)));
    cq_expect_completion(v_server, tag(101), GRPC_OP_OK);
    cq_verify(v_server);

    op = ops;
    op->op = GRPC_OP_SEND_INITIAL_METADATA;
    op->data.send_initial_metadata.count = 0;
    op++;
    op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
    op->data.send_status_from_server.trailing_metadata_count = 0;
    op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
    op->data.send_status_from_server.status_details = "xyz";
    op++;
    op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
    op->data.recv_close_on_server.cancelled = &was_cancelled;
    op++;
    GPR_ASSERT(GRPC_CALL_OK ==
               grpc_call_start_batch(s, ops, op - ops, tag(102)));

    cq_expect_completion(v_server, tag(102), GRPC_OP_OK);
    cq_verify(v_server);

    cq_expect_completion(v_client, tag(1), GRPC_OP_OK);
    cq_verify(v_client);

    GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
    GPR_ASSERT(0 == strcmp(details, "xyz"));
    GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
    GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
    GPR_ASSERT(was_cancelled == 0);

    grpc_call_destroy(s);
  } else {
    /* Check for a failed connection. */
    cq_expect_completion(v_client, tag(1), GRPC_OP_OK);
    cq_verify(v_client);

    GPR_ASSERT(status == GRPC_STATUS_DEADLINE_EXCEEDED);
  }

  grpc_call_destroy(c);

  cq_verifier_destroy(v_client);
  cq_verifier_destroy(v_server);

  /* Destroy client. */
  grpc_channel_destroy(client);
  grpc_completion_queue_shutdown(client_cq);
  drain_cq(client_cq);
  grpc_completion_queue_destroy(client_cq);

  /* Destroy server. */
  grpc_server_shutdown(server);
  grpc_server_destroy(server);
  grpc_completion_queue_shutdown(server_cq);
  drain_cq(server_cq);
  grpc_completion_queue_destroy(server_cq);
}
开发者ID:lijingang,项目名称:grpc,代码行数:101,代码来源:dualstack_socket_test.c

示例5: test_connect


//.........这里部分代码省略.........
  op->flags = expect_ok ? GRPC_INITIAL_METADATA_WAIT_FOR_READY : 0;
  op->reserved = NULL;
  op++;
  op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
  op->flags = 0;
  op->reserved = NULL;
  op++;
  op->op = GRPC_OP_RECV_INITIAL_METADATA;
  op->data.recv_initial_metadata = &initial_metadata_recv;
  op->flags = 0;
  op->reserved = NULL;
  op++;
  op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
  op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
  op->data.recv_status_on_client.status = &status;
  op->data.recv_status_on_client.status_details = &details;
  op->data.recv_status_on_client.status_details_capacity = &details_capacity;
  op->flags = 0;
  op->reserved = NULL;
  op++;
  error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
  GPR_ASSERT(GRPC_CALL_OK == error);

  if (expect_ok) {
    /* Check for a successful request. */
    error = grpc_server_request_call(server, &s, &call_details,
                                     &request_metadata_recv, cq, cq, tag(101));
    GPR_ASSERT(GRPC_CALL_OK == error);
    CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
    cq_verify(cqv);

    memset(ops, 0, sizeof(ops));
    op = ops;
    op->op = GRPC_OP_SEND_INITIAL_METADATA;
    op->data.send_initial_metadata.count = 0;
    op->flags = 0;
    op++;
    op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
    op->data.send_status_from_server.trailing_metadata_count = 0;
    op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
    op->data.send_status_from_server.status_details = "xyz";
    op->flags = 0;
    op++;
    op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
    op->data.recv_close_on_server.cancelled = &was_cancelled;
    op->flags = 0;
    op++;
    error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
    GPR_ASSERT(GRPC_CALL_OK == error);

    CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
    CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
    cq_verify(cqv);

    peer = grpc_call_get_peer(c);
    gpr_log(GPR_DEBUG, "got peer: '%s'", peer);
    gpr_free(peer);

    GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
    GPR_ASSERT(0 == strcmp(details, "xyz"));
    GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
    GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
    GPR_ASSERT(was_cancelled == 1);

    grpc_call_destroy(s);
  } else {
    /* Check for a failed connection. */
    CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
    cq_verify(cqv);

    GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE);
  }

  grpc_call_destroy(c);

  cq_verifier_destroy(cqv);

  /* Destroy client. */
  grpc_channel_destroy(client);

  /* Destroy server. */
  grpc_server_shutdown_and_notify(server, cq, tag(1000));
  GPR_ASSERT(grpc_completion_queue_pluck(
                 cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL)
                 .type == GRPC_OP_COMPLETE);
  grpc_server_destroy(server);
  grpc_completion_queue_shutdown(cq);
  drain_cq(cq);
  grpc_completion_queue_destroy(cq);

  grpc_metadata_array_destroy(&initial_metadata_recv);
  grpc_metadata_array_destroy(&trailing_metadata_recv);
  grpc_metadata_array_destroy(&request_metadata_recv);

  grpc_call_details_destroy(&call_details);
  gpr_free(details);
  if (picked_port) {
    grpc_recycle_unused_port(port);
  }
}
开发者ID:wilhuff,项目名称:grpc,代码行数:101,代码来源:dualstack_socket_test.c

示例6: test_connect


//.........这里部分代码省略.........

  /* Create server. */
  server_cq = grpc_completion_queue_create();
  server = grpc_server_create(server_cq, NULL);
  GPR_ASSERT((got_port = grpc_server_add_http2_port(server, server_hostport)) >
             0);
  if (port == 0) {
    port = got_port;
  } else {
    GPR_ASSERT(port == got_port);
  }
  grpc_server_start(server);
  v_server = cq_verifier_create(server_cq);

  /* Create client. */
  gpr_join_host_port(&client_hostport, client_host, port);
  client_cq = grpc_completion_queue_create();
  client = grpc_channel_create(client_hostport, NULL);
  v_client = cq_verifier_create(client_cq);

  gpr_log(GPR_INFO, "Testing with server=%s client=%s (expecting %s)",
          server_hostport, client_hostport, expect_ok ? "success" : "failure");

  gpr_free(client_hostport);
  gpr_free(server_hostport);

  if (expect_ok) {
    /* Normal deadline, shouldn't be reached. */
    deadline = ms_from_now(60000);
  } else {
    /* Give up faster when failure is expected.
       BUG: Setting this to 1000 reveals a memory leak (b/18608927). */
    deadline = ms_from_now(1500);
  }

  /* Send a trivial request. */
  c = grpc_channel_create_call_old(client, "/foo", "foo.test.google.fr",
                                   deadline);
  GPR_ASSERT(c);

  GPR_ASSERT(GRPC_CALL_OK ==
             grpc_call_invoke_old(c, client_cq, tag(2), tag(3), 0));
  GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done_old(c, tag(4)));
  if (expect_ok) {
    /* Check for a successful request. */
    cq_expect_finish_accepted(v_client, tag(4), GRPC_OP_OK);
    cq_verify(v_client);

    GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(server, tag(100)));
    cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo",
                             "foo.test.google.fr", deadline, NULL);
    cq_verify(v_server);

    GPR_ASSERT(GRPC_CALL_OK ==
               grpc_call_server_accept_old(s, server_cq, tag(102)));
    GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata_old(s, 0));
    cq_expect_client_metadata_read(v_client, tag(2), NULL);
    cq_verify(v_client);

    GPR_ASSERT(GRPC_CALL_OK ==
               grpc_call_start_write_status_old(s, GRPC_STATUS_UNIMPLEMENTED,
                                                "xyz", tag(5)));
    cq_expect_finished_with_status(v_client, tag(3), GRPC_STATUS_UNIMPLEMENTED,
                                   "xyz", NULL);
    cq_verify(v_client);

    cq_expect_finish_accepted(v_server, tag(5), GRPC_OP_OK);
    cq_expect_finished(v_server, tag(102), NULL);
    cq_verify(v_server);

    grpc_call_destroy(c);
    grpc_call_destroy(s);
  } else {
    /* Check for a failed connection. */
    cq_expect_client_metadata_read(v_client, tag(2), NULL);
    cq_expect_finished_with_status(v_client, tag(3),
                                   GRPC_STATUS_DEADLINE_EXCEEDED,
                                   "Deadline Exceeded", NULL);
    cq_expect_finish_accepted(v_client, tag(4), GRPC_OP_ERROR);
    cq_verify(v_client);

    grpc_call_destroy(c);
  }

  cq_verifier_destroy(v_client);
  cq_verifier_destroy(v_server);

  /* Destroy client. */
  grpc_channel_destroy(client);
  grpc_completion_queue_shutdown(client_cq);
  drain_cq(client_cq);
  grpc_completion_queue_destroy(client_cq);

  /* Destroy server. */
  grpc_server_shutdown(server);
  grpc_server_destroy(server);
  grpc_completion_queue_shutdown(server_cq);
  drain_cq(server_cq);
  grpc_completion_queue_destroy(server_cq);
}
开发者ID:Abioy,项目名称:kythe,代码行数:101,代码来源:dualstack_socket_test.c


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