GRPC Core 0.10.0.0

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Enumerations | Functions
call.c File Reference
`#include <assert.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <grpc/compression.h>`
`#include <grpc/support/alloc.h>`
`#include <grpc/support/log.h>`
`#include <grpc/support/string_util.h>`
`#include "src/core/channel/channel_stack.h"`
`#include "src/core/iomgr/alarm.h"`
`#include "src/core/profiling/timers.h"`
`#include "src/core/surface/byte_buffer_queue.h"`
`#include "src/core/surface/call.h"`
`#include "src/core/surface/channel.h"`
`#include "src/core/surface/completion_queue.h"`

## Data Structures
struct | completed_request
struct | reqinfo_master
struct | received_status
struct | grpc_call
struct | finished_loose_op_allocated_args

## Macros
#define | MAX_CONCURRENT_COMPLETIONS 6
| The maximum number of completions possible. More...
#define | REQSET_EMPTY 'X'
#define | REQSET_DONE 'Y'
#define | MAX_SEND_INITIAL_METADATA_COUNT 3
#define | CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1))
#define | CALL_FROM_CALL_STACK(call_stack) (((grpc_call *)(call_stack)) - 1)
#define | CALL_ELEM_FROM_CALL(call, idx) grpc_call_stack_element(CALL_STACK_FROM_CALL(call), idx)
#define | CALL_FROM_TOP_ELEM(top_elem) CALL_FROM_CALL_STACK(grpc_call_stack_from_top_element(top_elem))
#define | STATUS_OFFSET 1
#define | COMPRESS_OFFSET 1

## Enumerations
enum | req_state { REQ_INITIAL = 0, REQ_READY, REQ_DONE }
enum | send_action { SEND_NOTHING, SEND_INITIAL_METADATA, SEND_BUFFERED_INITIAL_METADATA, SEND_MESSAGE, SEND_BUFFERED_MESSAGE, SEND_TRAILING_METADATA_AND_FINISH, SEND_FINISH }
enum | status_source { STATUS_FROM_API_OVERRIDE = 0, STATUS_FROM_CORE, STATUS_FROM_WIRE, STATUS_FROM_SERVER_STATUS, STATUS_SOURCE_COUNT }
enum | read_state { READ_STATE_INITIAL = 0, READ_STATE_GOT_INITIAL_METADATA, READ_STATE_READ_CLOSED, READ_STATE_STREAM_CLOSED }
enum | write_state { WRITE_STATE_INITIAL = 0, WRITE_STATE_STARTED, WRITE_STATE_WRITE_CLOSED }

## Functions
grpc_call * | grpc_call_create (grpc_channel *channel, grpc_completion_queue *cq, const void *server_transport_data, grpc_mdelem **add_initial_metadata, size_t add_initial_metadata_count, gpr_timespec send_deadline)
void | grpc_call_set_completion_queue (grpc_call *call, grpc_completion_queue *cq)
grpc_completion_queue * | grpc_call_get_completion_queue (grpc_call *call)
void | grpc_call_internal_ref (grpc_call *c)
void | grpc_call_internal_unref (grpc_call *c, int allow_immediate_deletion)
grpc_compression_algorithm | grpc_call_get_compression_algorithm (const grpc_call *call)
grpc_call_error | grpc_call_start_ioreq_and_call_back (grpc_call *call, const grpc_ioreq *reqs, size_t nreqs, grpc_ioreq_completion_func on_complete, void *user_data)
void | grpc_call_destroy (grpc_call *c)
| Destroy a call. More...
grpc_call_error | grpc_call_cancel (grpc_call *call)
| Called by clients to cancel an RPC on the server. More...
grpc_call_error | grpc_call_cancel_with_status (grpc_call *c, grpc_status_code status, const char *description)
| Called by clients to cancel an RPC on the server. More...
char * | grpc_call_get_peer (grpc_call *call)
| Returns a newly allocated string representing the endpoint to which this call is communicating with. More...
grpc_call * | grpc_call_from_top_element (grpc_call_element *elem)
grpc_call_stack * | grpc_call_get_call_stack (grpc_call *call)
grpc_call_error | grpc_call_start_batch (grpc_call *call, const grpc_op *ops, size_t nops, void *tag)
| Start a batch of operations defined in the array ops; when complete, post a completion of type 'tag' to the completion queue bound to the call. More...
void | grpc_call_context_set (grpc_call *call, grpc_context_index elem, void *value, void(*destroy)(void *value))
void * | grpc_call_context_get (grpc_call *call, grpc_context_index elem)
gpr_uint8 | grpc_call_is_client (grpc_call *call)

## Macro Definition Documentation

#define CALL_ELEM_FROM_CALL | ( |  | call,
|  |  | idx
| ) |  | grpc_call_stack_element(CALL_STACK_FROM_CALL(call), idx)

#define CALL_FROM_CALL_STACK | ( |  | call_stack | ) | (((grpc_call *)(call_stack)) - 1)

#define CALL_FROM_TOP_ELEM | ( |  | top_elem | ) | CALL_FROM_CALL_STACK(grpc_call_stack_from_top_element(top_elem))

#define CALL_STACK_FROM_CALL | ( |  | call | ) | ((grpc_call_stack *)((call) + 1))

#define COMPRESS_OFFSET 1

#define MAX_CONCURRENT_COMPLETIONS 6

The maximum number of completions possible.

Based upon the maximum number of individually queueable ops in the batch api:

- initial metadata send
- message send
- status/close send (depending on client/server)
- initial metadata recv
- message recv
- status/close recv (depending on client/server)

#define MAX_SEND_INITIAL_METADATA_COUNT 3

#define REQSET_DONE 'Y'

#define REQSET_EMPTY 'X'

#define STATUS_OFFSET 1

## Enumeration Type Documentation

enum read_state

Enumerator
READ_STATE_INITIAL |
READ_STATE_GOT_INITIAL_METADATA |
READ_STATE_READ_CLOSED |
READ_STATE_STREAM_CLOSED |

enum req_state

Enumerator
REQ_INITIAL |
REQ_READY |
REQ_DONE |

enum send_action

Enumerator
SEND_NOTHING |
SEND_INITIAL_METADATA |
SEND_BUFFERED_INITIAL_METADATA |
SEND_MESSAGE |
SEND_BUFFERED_MESSAGE |
SEND_TRAILING_METADATA_AND_FINISH |
SEND_FINISH |

enum status_source

Enumerator
STATUS_FROM_API_OVERRIDE |
STATUS_FROM_CORE |
STATUS_FROM_WIRE |
STATUS_FROM_SERVER_STATUS |
STATUS_SOURCE_COUNT |

enum write_state

Enumerator
WRITE_STATE_INITIAL |
WRITE_STATE_STARTED |
WRITE_STATE_WRITE_CLOSED |

## Function Documentation

grpc_call_error grpc_call_cancel | ( | grpc_call * | call | ) |

Called by clients to cancel an RPC on the server.

Can be called multiple times, from any thread. THREAD-SAFETY grpc_call_cancel and grpc_call_cancel_with_status are thread-safe, and can be called at any point before grpc_call_destroy is called.

grpc_call_error grpc_call_cancel_with_status | ( | grpc_call * | call,
|  | grpc_status_code | status,
|  | const char * | description
| ) |  |

Called by clients to cancel an RPC on the server.

Can be called multiple times, from any thread. If a status has not been received for the call, set it to the status code and description passed in. Importantly, this function does not send status nor description to the remote endpoint.

void* grpc_call_context_get | ( | grpc_call * | call,
|  | grpc_context_index | elem
| ) |  |

void grpc_call_context_set | ( | grpc_call * | call,
|  | grpc_context_index | elem,
|  | void * | value,
|  | void(*)(void *value) | destroy
| ) |  |

grpc_call* grpc_call_create | ( | grpc_channel * | channel,
|  | grpc_completion_queue * | cq,
|  | const void * | server_transport_data,
|  | grpc_mdelem ** | add_initial_metadata,
|  | size_t | add_initial_metadata_count,
|  | gpr_timespec | send_deadline
| ) |  |

void grpc_call_destroy | ( | grpc_call * | call | ) |

Destroy a call.

THREAD SAFETY: grpc_call_destroy is thread-compatible

grpc_call* grpc_call_from_top_element | ( | grpc_call_element * | elem | ) |

grpc_call_stack* grpc_call_get_call_stack | ( | grpc_call * | call | ) |

grpc_completion_queue* grpc_call_get_completion_queue | ( | grpc_call * | call | ) |

grpc_compression_algorithm grpc_call_get_compression_algorithm | ( | const grpc_call * | call | ) |

char* grpc_call_get_peer | ( | grpc_call * | call | ) |

Returns a newly allocated string representing the endpoint to which this call is communicating with.

The string is in the uri format accepted by grpc_channel_create. The returned string should be disposed of with gpr_free().

WARNING: this value is never authenticated or subject to any security related code. It must not be used for any authentication related functionality. Instead, use grpc_auth_context.

void grpc_call_internal_ref | ( | grpc_call * | c | ) |

void grpc_call_internal_unref | ( | grpc_call * | c,
|  | int | allow_immediate_deletion
| ) |  |

gpr_uint8 grpc_call_is_client | ( | grpc_call * | call | ) |

void grpc_call_set_completion_queue | ( | grpc_call * | call,
|  | grpc_completion_queue * | cq
| ) |  |

grpc_call_error grpc_call_start_batch | ( | grpc_call * | call,
|  | const grpc_op * | ops,
|  | size_t | nops,
|  | void * | tag
| ) |  |

Start a batch of operations defined in the array ops; when complete, post a completion of type 'tag' to the completion queue bound to the call.

The order of ops specified in the batch has no significance. Only one operation of each type can be active at once in any given batch. You must call grpc_completion_queue_next or grpc_completion_queue_pluck on the completion queue associated with 'call' for work to be performed. THREAD SAFETY: access to grpc_call_start_batch in multi-threaded environment needs to be synchronized. As an optimization, you may synchronize batches containing just send operations independently from batches containing just receive operations.

grpc_call_error grpc_call_start_ioreq_and_call_back | ( | grpc_call * | call,
|  | const grpc_ioreq * | reqs,
|  | size_t | nreqs,
|  | grpc_ioreq_completion_func | on_complete,
|  | void * | user_data
| ) |  |