aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/iomgr/endpoint.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/iomgr/endpoint.h')
-rw-r--r--src/core/iomgr/endpoint.h63
1 files changed, 35 insertions, 28 deletions
diff --git a/src/core/iomgr/endpoint.h b/src/core/iomgr/endpoint.h
index d14d52d561..ea92a500e8 100644
--- a/src/core/iomgr/endpoint.h
+++ b/src/core/iomgr/endpoint.h
@@ -37,7 +37,6 @@
#include "src/core/iomgr/pollset.h"
#include "src/core/iomgr/pollset_set.h"
#include <grpc/support/slice.h>
-#include <grpc/support/slice_buffer.h>
#include <grpc/support/time.h>
/* An endpoint caps a streaming channel between two communicating processes.
@@ -46,17 +45,31 @@
typedef struct grpc_endpoint grpc_endpoint;
typedef struct grpc_endpoint_vtable grpc_endpoint_vtable;
-typedef enum grpc_endpoint_op_status {
- GRPC_ENDPOINT_DONE, /* completed immediately, cb won't be called */
- GRPC_ENDPOINT_PENDING, /* cb will be called when completed */
- GRPC_ENDPOINT_ERROR /* write errored out, cb won't be called */
-} grpc_endpoint_op_status;
+typedef enum grpc_endpoint_cb_status {
+ GRPC_ENDPOINT_CB_OK = 0, /* Call completed successfully */
+ GRPC_ENDPOINT_CB_EOF, /* Call completed successfully, end of file reached */
+ GRPC_ENDPOINT_CB_SHUTDOWN, /* Call interrupted by shutdown */
+ GRPC_ENDPOINT_CB_ERROR /* Call interrupted by socket error */
+} grpc_endpoint_cb_status;
+
+typedef enum grpc_endpoint_write_status {
+ GRPC_ENDPOINT_WRITE_DONE, /* completed immediately, cb won't be called */
+ GRPC_ENDPOINT_WRITE_PENDING, /* cb will be called when completed */
+ GRPC_ENDPOINT_WRITE_ERROR /* write errored out, cb won't be called */
+} grpc_endpoint_write_status;
+
+typedef void (*grpc_endpoint_read_cb)(void *user_data, gpr_slice *slices,
+ size_t nslices,
+ grpc_endpoint_cb_status error);
+typedef void (*grpc_endpoint_write_cb)(void *user_data,
+ grpc_endpoint_cb_status error);
struct grpc_endpoint_vtable {
- grpc_endpoint_op_status (*read)(grpc_endpoint *ep, gpr_slice_buffer *slices,
- grpc_iomgr_closure *cb);
- grpc_endpoint_op_status (*write)(grpc_endpoint *ep, gpr_slice_buffer *slices,
- grpc_iomgr_closure *cb);
+ void (*notify_on_read)(grpc_endpoint *ep, grpc_endpoint_read_cb cb,
+ void *user_data);
+ grpc_endpoint_write_status (*write)(grpc_endpoint *ep, gpr_slice *slices,
+ size_t nslices, grpc_endpoint_write_cb cb,
+ void *user_data);
void (*add_to_pollset)(grpc_endpoint *ep, grpc_pollset *pollset);
void (*add_to_pollset_set)(grpc_endpoint *ep, grpc_pollset_set *pollset);
void (*shutdown)(grpc_endpoint *ep);
@@ -64,32 +77,26 @@ struct grpc_endpoint_vtable {
char *(*get_peer)(grpc_endpoint *ep);
};
-/* When data is available on the connection, calls the callback with slices.
- Callback success indicates that the endpoint can accept more reads, failure
- indicates the endpoint is closed.
- Valid slices may be placed into \a slices even on callback success == 0. */
-grpc_endpoint_op_status grpc_endpoint_read(
- grpc_endpoint *ep, gpr_slice_buffer *slices,
- grpc_iomgr_closure *cb) GRPC_MUST_USE_RESULT;
+/* When data is available on the connection, calls the callback with slices. */
+void grpc_endpoint_notify_on_read(grpc_endpoint *ep, grpc_endpoint_read_cb cb,
+ void *user_data);
char *grpc_endpoint_get_peer(grpc_endpoint *ep);
/* Write slices out to the socket.
If the connection is ready for more data after the end of the call, it
- returns GRPC_ENDPOINT_DONE.
- Otherwise it returns GRPC_ENDPOINT_PENDING and calls cb when the
- connection is ready for more data.
- \a slices may be mutated at will by the endpoint until cb is called.
- No guarantee is made to the content of slices after a write EXCEPT that
- it is a valid slice buffer.
- */
-grpc_endpoint_op_status grpc_endpoint_write(
- grpc_endpoint *ep, gpr_slice_buffer *slices,
- grpc_iomgr_closure *cb) GRPC_MUST_USE_RESULT;
+ returns GRPC_ENDPOINT_WRITE_DONE.
+ Otherwise it returns GRPC_ENDPOINT_WRITE_PENDING and calls cb when the
+ connection is ready for more data. */
+grpc_endpoint_write_status grpc_endpoint_write(grpc_endpoint *ep,
+ gpr_slice *slices,
+ size_t nslices,
+ grpc_endpoint_write_cb cb,
+ void *user_data);
/* Causes any pending read/write callbacks to run immediately with
- success==0 */
+ GRPC_ENDPOINT_CB_SHUTDOWN status */
void grpc_endpoint_shutdown(grpc_endpoint *ep);
void grpc_endpoint_destroy(grpc_endpoint *ep);