GRPC Core  0.11.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
endpoint.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_H
35 #define GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_H
36 
37 #include "src/core/iomgr/pollset.h"
39 #include <grpc/support/slice.h>
41 #include <grpc/support/time.h>
42 
43 /* An endpoint caps a streaming channel between two communicating processes.
44  Examples may be: a tcp socket, <stdin+stdout>, or some shared memory. */
45 
48 
50  GRPC_ENDPOINT_DONE, /* completed immediately, cb won't be called */
51  GRPC_ENDPOINT_PENDING, /* cb will be called when completed */
52  GRPC_ENDPOINT_ERROR /* write errored out, cb won't be called */
54 
57  grpc_iomgr_closure *cb);
59  grpc_iomgr_closure *cb);
60  void (*add_to_pollset)(grpc_endpoint *ep, grpc_pollset *pollset);
62  void (*shutdown)(grpc_endpoint *ep);
63  void (*destroy)(grpc_endpoint *ep);
64  char *(*get_peer)(grpc_endpoint *ep);
65 };
66 
67 /* When data is available on the connection, calls the callback with slices.
68  Callback success indicates that the endpoint can accept more reads, failure
69  indicates the endpoint is closed.
70  Valid slices may be placed into \a slices even on callback success == 0. */
72  grpc_endpoint *ep, gpr_slice_buffer *slices,
74 
76 
77 /* Write slices out to the socket.
78 
79  If the connection is ready for more data after the end of the call, it
80  returns GRPC_ENDPOINT_DONE.
81  Otherwise it returns GRPC_ENDPOINT_PENDING and calls cb when the
82  connection is ready for more data.
83  \a slices may be mutated at will by the endpoint until cb is called.
84  No guarantee is made to the content of slices after a write EXCEPT that
85  it is a valid slice buffer.
86  */
88  grpc_endpoint *ep, gpr_slice_buffer *slices,
90 
91 /* Causes any pending read/write callbacks to run immediately with
92  success==0 */
95 
96 /* Add an endpoint to a pollset, so that when the pollset is polled, events from
97  this endpoint are considered */
100  grpc_pollset_set *pollset_set);
101 
104 };
105 
106 #endif /* GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_H */
void(* add_to_pollset)(grpc_endpoint *ep, grpc_pollset *pollset)
Definition: endpoint.h:60
grpc_endpoint_op_status(* read)(grpc_endpoint *ep, gpr_slice_buffer *slices, grpc_iomgr_closure *cb)
Definition: endpoint.h:56
void(* shutdown)(grpc_endpoint *ep)
Definition: endpoint.h:62
void(* add_to_pollset_set)(grpc_endpoint *ep, grpc_pollset_set *pollset)
Definition: endpoint.h:61
#define GRPC_MUST_USE_RESULT
Definition: port_platform.h:330
void grpc_endpoint_destroy(grpc_endpoint *ep)
Definition: endpoint.c:59
char * grpc_endpoint_get_peer(grpc_endpoint *ep)
Definition: endpoint.c:61
Definition: pollset_posix.h:55
Definition: slice_buffer.h:48
const grpc_endpoint_vtable * vtable
Definition: endpoint.h:103
Definition: endpoint.h:55
Definition: endpoint.h:50
void grpc_endpoint_add_to_pollset_set(grpc_endpoint *ep, grpc_pollset_set *pollset_set)
Definition: endpoint.c:52
grpc_endpoint_op_status(* write)(grpc_endpoint *ep, gpr_slice_buffer *slices, grpc_iomgr_closure *cb)
Definition: endpoint.h:58
Definition: endpoint.h:51
void(* destroy)(grpc_endpoint *ep)
Definition: endpoint.h:63
A closure over a grpc_iomgr_cb_func.
Definition: iomgr.h:45
grpc_endpoint_op_status grpc_endpoint_read(grpc_endpoint *ep, gpr_slice_buffer *slices, grpc_iomgr_closure *cb) GRPC_MUST_USE_RESULT
Definition: endpoint.c:36
grpc_endpoint_op_status grpc_endpoint_write(grpc_endpoint *ep, gpr_slice_buffer *slices, grpc_iomgr_closure *cb) GRPC_MUST_USE_RESULT
Definition: endpoint.c:42
void grpc_endpoint_add_to_pollset(grpc_endpoint *ep, grpc_pollset *pollset)
Definition: endpoint.c:48
Definition: endpoint.h:102
Definition: pollset_set_posix.h:40
void grpc_endpoint_shutdown(grpc_endpoint *ep)
Definition: endpoint.c:57
grpc_endpoint_op_status
Definition: endpoint.h:49
Definition: endpoint.h:52