diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc/grpc.h | 70 | ||||
-rw-r--r-- | include/grpc/support/thd.h | 13 | ||||
-rw-r--r-- | include/grpc/support/thd_posix.h | 42 | ||||
-rw-r--r-- | include/grpc/support/thd_win32.h | 44 | ||||
-rw-r--r-- | include/grpc/support/time.h | 29 | ||||
-rw-r--r-- | include/grpc/support/time_posix.h | 43 | ||||
-rw-r--r-- | include/grpc/support/time_win32.h | 46 |
7 files changed, 75 insertions, 212 deletions
diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index a9fae0df90..c18e47e54b 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -183,17 +183,16 @@ typedef struct grpc_metadata { } grpc_metadata; typedef enum grpc_completion_type { - GRPC_QUEUE_SHUTDOWN, /* Shutting down */ - GRPC_READ, /* A read has completed */ - GRPC_INVOKE_ACCEPTED, /* An invoke call has been accepted by flow - control */ - GRPC_WRITE_ACCEPTED, /* A write has been accepted by - flow control */ + GRPC_QUEUE_SHUTDOWN, /* Shutting down */ + GRPC_IOREQ, /* grpc_call_ioreq completion */ + GRPC_READ, /* A read has completed */ + GRPC_WRITE_ACCEPTED, /* A write has been accepted by + flow control */ GRPC_FINISH_ACCEPTED, /* writes_done or write_status has been accepted */ GRPC_CLIENT_METADATA_READ, /* The metadata array sent by server received at client */ - GRPC_FINISHED, /* An RPC has finished. The event contains status. - On the server this will be OK or Cancelled. */ + GRPC_FINISHED, /* An RPC has finished. The event contains status. + On the server this will be OK or Cancelled. */ GRPC_SERVER_RPC_NEW, /* A new RPC has arrived at the server */ GRPC_SERVER_SHUTDOWN, /* The server has finished shutting down */ GRPC_COMPLETION_DO_NOT_USE /* must be last, forces users to include @@ -213,6 +212,7 @@ typedef struct grpc_event { grpc_op_error write_accepted; grpc_op_error finish_accepted; grpc_op_error invoke_accepted; + grpc_op_error ioreq; struct { size_t count; grpc_metadata *elements; @@ -233,6 +233,57 @@ typedef struct grpc_event { } data; } grpc_event; +typedef struct { + size_t count; + size_t capacity; + grpc_metadata *metadata; +} grpc_metadata_array; + +typedef struct { + const char *method; + const char *host; + gpr_timespec deadline; +} grpc_call_details; + +typedef enum { + GRPC_OP_SEND_INITIAL_METADATA = 0, + GRPC_OP_SEND_MESSAGE, + GRPC_OP_SEND_CLOSE_FROM_CLIENT, + GRPC_OP_SEND_STATUS_FROM_SERVER, + GRPC_OP_RECV_INITIAL_METADATA, + GRPC_OP_RECV_MESSAGES, + GRPC_OP_RECV_STATUS_ON_CLIENT, + GRPC_OP_RECV_CLOSE_ON_SERVER +} grpc_op_type; + +typedef struct grpc_op { + grpc_op_type op; + union { + struct { + size_t count; + const grpc_metadata *metadata; + } send_initial_metadata; + grpc_byte_buffer *send_message; + struct { + size_t trailing_metadata_count; + grpc_metadata *trailing_metadata; + grpc_status_code status; + const char *status_details; + } send_status_from_server; + grpc_metadata_array *recv_initial_metadata; + grpc_byte_buffer **recv_message; + struct { + grpc_metadata_array *trailing_metadata; + grpc_status_code *status; + char **status_details; + size_t *status_details_capacity; + } recv_status_on_client; + struct { + int *cancelled; + } recv_close_on_server; + } data; +} grpc_op; + /* Initialize the grpc library */ void grpc_init(void); @@ -279,6 +330,9 @@ grpc_call *grpc_channel_create_call_old(grpc_channel *channel, const char *method, const char *host, gpr_timespec deadline); +grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops, + size_t nops, void *tag); + /* Create a client channel */ grpc_channel *grpc_channel_create(const char *target, const grpc_channel_args *args); diff --git a/include/grpc/support/thd.h b/include/grpc/support/thd.h index 91e0c9f16f..92d40b4475 100644 --- a/include/grpc/support/thd.h +++ b/include/grpc/support/thd.h @@ -44,18 +44,12 @@ #include <grpc/support/port_platform.h> -#if defined(GPR_POSIX_SYNC) -#include <grpc/support/thd_posix.h> -#elif defined(GPR_WIN32) -#include <grpc/support/thd_win32.h> -#else -#error could not determine platform for thd -#endif - #ifdef __cplusplus extern "C" { #endif +typedef gpr_uint64 gpr_thd_id; + /* Thread creation options. */ typedef struct { int flags; /* Flags below can be set here. Default value 0. */ @@ -72,6 +66,9 @@ int gpr_thd_new(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg, /* Return a gpr_thd_options struct with all fields set to defaults. */ gpr_thd_options gpr_thd_options_default(void); +/* Returns the identifier of the current thread. */ +gpr_thd_id gpr_thd_currentid(void); + #ifdef __cplusplus } #endif diff --git a/include/grpc/support/thd_posix.h b/include/grpc/support/thd_posix.h deleted file mode 100644 index b688e45bc5..0000000000 --- a/include/grpc/support/thd_posix.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Copyright 2014, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __GRPC_SUPPORT_THD_POSIX_H__ -#define __GRPC_SUPPORT_THD_POSIX_H__ -/* Posix variant of gpr_thd_platform.h. */ - -#include <pthread.h> - -typedef pthread_t gpr_thd_id; - -#endif /* __GRPC_SUPPORT_THD_POSIX_H__ */ diff --git a/include/grpc/support/thd_win32.h b/include/grpc/support/thd_win32.h deleted file mode 100644 index b4ab3c7271..0000000000 --- a/include/grpc/support/thd_win32.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Copyright 2014, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __GRPC_SUPPORT_THD_WIN32_H__ -#define __GRPC_SUPPORT_THD_WIN32_H__ - -/* Win32 variant of gpr_thd_platform.h */ - -#include <windows.h> -#include <grpc/support/atm.h> - -typedef int gpr_thd_id; - -#endif /* __GRPC_SUPPORT_THD_WIN32_H__ */ diff --git a/include/grpc/support/time.h b/include/grpc/support/time.h index 6327a2cffb..9fb1d0bc97 100644 --- a/include/grpc/support/time.h +++ b/include/grpc/support/time.h @@ -34,31 +34,22 @@ #ifndef __GRPC_SUPPORT_TIME_H__ #define __GRPC_SUPPORT_TIME_H__ /* Time support. - We use gpr_timespec, which is typedefed to struct timespec on platforms which - have it. On some machines, absolute times may be in local time. */ - -/* Platform specific header declares gpr_timespec. - gpr_timespec contains: - time_t tv_sec; // seconds since start of 1970 - int tv_nsec; // nanoseconds; always in 0..999999999; never negative. - */ + We use gpr_timespec, which is analogous to struct timespec. On some + machines, absolute times may be in local time. */ #include <grpc/support/port_platform.h> - -#if defined(GPR_POSIX_TIME) -#include <grpc/support/time_posix.h> -#elif defined(GPR_WIN32) -#include <grpc/support/time_win32.h> -#else -#error could not determine platform for time -#endif - #include <stddef.h> +#include <time.h> #ifdef __cplusplus extern "C" { #endif +typedef struct gpr_timespec { + time_t tv_sec; + int tv_nsec; +} gpr_timespec; + /* Time constants. */ extern const gpr_timespec gpr_time_0; /* The zero time interval. */ extern const gpr_timespec gpr_inf_future; /* The far future */ @@ -103,10 +94,6 @@ int gpr_time_similar(gpr_timespec a, gpr_timespec b, gpr_timespec threshold); /* Sleep until at least 'until' - an absolute timeout */ void gpr_sleep_until(gpr_timespec until); -struct timeval gpr_timeval_from_timespec(gpr_timespec t); - -gpr_timespec gpr_timespec_from_timeval(struct timeval t); - double gpr_timespec_to_micros(gpr_timespec t); #ifdef __cplusplus diff --git a/include/grpc/support/time_posix.h b/include/grpc/support/time_posix.h deleted file mode 100644 index 9ff6f7f493..0000000000 --- a/include/grpc/support/time_posix.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * Copyright 2014, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __GRPC_SUPPORT_TIME_POSIX_H__ -#define __GRPC_SUPPORT_TIME_POSIX_H__ -/* Posix variant of gpr_time_platform.h */ - -#include <sys/time.h> -#include <time.h> - -typedef struct timespec gpr_timespec; - -#endif /* __GRPC_SUPPORT_TIME_POSIX_H__ */ diff --git a/include/grpc/support/time_win32.h b/include/grpc/support/time_win32.h deleted file mode 100644 index e62ad64b8f..0000000000 --- a/include/grpc/support/time_win32.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Copyright 2014, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __GRPC_SUPPORT_TIME_WIN32_H__ -#define __GRPC_SUPPORT_TIME_WIN32_H__ -/* Win32 variant of gpr_time_platform.h */ - -#include <Winsock.h> -#include <time.h> - -typedef struct gpr_timespec { - time_t tv_sec; - long tv_nsec; -} gpr_timespec; - -#endif /* __GRPC_SUPPORT_TIME_WIN32_H__ */ |