89 lines
19 KiB
HTML
89 lines
19 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.13"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>GRPC C++: include/grpcpp/impl/codegen/message_allocator.h Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">GRPC C++
|
|
 <span id="projectnumber">1.22.0</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.13 -->
|
|
<script type="text/javascript">
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
</script>
|
|
<div id="main-nav"></div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div id="nav-path" class="navpath">
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_412f9a3d5dfcba8716486cd870ef4586.html">grpcpp</a></li><li class="navelem"><a class="el" href="dir_84040d6f573b73aa8d12512b533ede11.html">impl</a></li><li class="navelem"><a class="el" href="dir_a33e3e3a3b205cffecbb359564791f71.html">codegen</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">message_allocator.h</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<a href="impl_2codegen_2message__allocator_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">/*</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"> *</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> * Copyright 2019 gRPC authors.</span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> *</span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> * you may not use this file except in compliance with the License.</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> * You may obtain a copy of the License at</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"> *</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> *</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> * See the License for the specific language governing permissions and</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"> * limitations under the License.</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment"> *</span></div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment"> */</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> </div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="preprocessor">#ifndef GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="preprocessor">#define GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H</span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> </div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="keyword">namespace </span><a class="code" href="namespacegrpc.html">grpc</a> {</div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="keyword">namespace </span>experimental {</div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> </div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="comment">// NOTE: This is an API for advanced users who need custom allocators.</span></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="comment">// Per rpc struct for the allocator. This is the interface to return to user.</span></div><div class="line"><a name="l00027"></a><span class="lineno"><a class="line" href="classgrpc_1_1experimental_1_1_rpc_allocator_state.html"> 27</a></span> <span class="keyword">class </span><a class="code" href="classgrpc_1_1experimental_1_1_rpc_allocator_state.html">RpcAllocatorState</a> {</div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span>  <span class="keyword">virtual</span> <a class="code" href="classgrpc_1_1experimental_1_1_rpc_allocator_state.html#aa2f076faaed3c8f2b7a113bf38e9c9dd">~RpcAllocatorState</a>() = <span class="keywordflow">default</span>;</div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span>  <span class="comment">// Optionally deallocate request early to reduce the size of working set.</span></div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span>  <span class="comment">// A custom MessageAllocator needs to be registered to make use of this.</span></div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span>  <span class="comment">// This is not abstract because implementing it is optional.</span></div><div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="classgrpc_1_1experimental_1_1_rpc_allocator_state.html#a75dc7544cb4886b53fcc5a7c98e525f5"> 33</a></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classgrpc_1_1experimental_1_1_rpc_allocator_state.html#a75dc7544cb4886b53fcc5a7c98e525f5">FreeRequest</a>() {}</div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> };</div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span> </div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span> <span class="comment">// This is the interface returned by the allocator.</span></div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span> <span class="comment">// grpc library will call the methods to get request/response pointers and to</span></div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span> <span class="comment">// release the object when it is done.</span></div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span> <span class="keyword">template</span> <<span class="keyword">typename</span> RequestT, <span class="keyword">typename</span> ResponseT></div><div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="classgrpc_1_1experimental_1_1_message_holder.html"> 40</a></span> <span class="keyword">class </span><a class="code" href="classgrpc_1_1experimental_1_1_message_holder.html">MessageHolder</a> : <span class="keyword">public</span> <a class="code" href="classgrpc_1_1experimental_1_1_rpc_allocator_state.html">RpcAllocatorState</a> {</div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  <span class="comment">// Release this object. For example, if the custom allocator's</span></div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  <span class="comment">// AllocateMessasge creates an instance of a subclass with new, the Release()</span></div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span>  <span class="comment">// should do a "delete this;".</span></div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> Release() = 0;</div><div class="line"><a name="l00046"></a><span class="lineno"><a class="line" href="classgrpc_1_1experimental_1_1_message_holder.html#af8dfca1336d734a4f3406327d35e22b7"> 46</a></span>  RequestT* <a class="code" href="classgrpc_1_1experimental_1_1_message_holder.html#af8dfca1336d734a4f3406327d35e22b7">request</a>() { <span class="keywordflow">return</span> request_; }</div><div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="classgrpc_1_1experimental_1_1_message_holder.html#a169fb5a4b742b8a55b04fc9dec54aecb"> 47</a></span>  ResponseT* <a class="code" href="classgrpc_1_1experimental_1_1_message_holder.html#a169fb5a4b742b8a55b04fc9dec54aecb">response</a>() { <span class="keywordflow">return</span> response_; }</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span> </div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  <span class="keyword">protected</span>:</div><div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="classgrpc_1_1experimental_1_1_message_holder.html#a3c627621eb7f90440e0fae41ebdbae10"> 50</a></span>  <span class="keywordtype">void</span> <a class="code" href="classgrpc_1_1experimental_1_1_message_holder.html#a3c627621eb7f90440e0fae41ebdbae10">set_request</a>(RequestT* request) { request_ = request; }</div><div class="line"><a name="l00051"></a><span class="lineno"><a class="line" href="classgrpc_1_1experimental_1_1_message_holder.html#a8bed5c98e17cff87b7641d527c84fac3"> 51</a></span>  <span class="keywordtype">void</span> <a class="code" href="classgrpc_1_1experimental_1_1_message_holder.html#a8bed5c98e17cff87b7641d527c84fac3">set_response</a>(ResponseT* response) { response_ = response; }</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span> </div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  <span class="comment">// NOTE: subclasses should set these pointers.</span></div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  RequestT* request_;</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  ResponseT* response_;</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span> };</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span> </div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span> <span class="comment">// A custom allocator can be set via the generated code to a callback unary</span></div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span> <span class="comment">// method, such as SetMessageAllocatorFor_Echo(custom_allocator). The allocator</span></div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span> <span class="comment">// needs to be alive for the lifetime of the server.</span></div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span> <span class="comment">// Implementations need to be thread-safe.</span></div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span> <span class="keyword">template</span> <<span class="keyword">typename</span> RequestT, <span class="keyword">typename</span> ResponseT></div><div class="line"><a name="l00064"></a><span class="lineno"><a class="line" href="classgrpc_1_1experimental_1_1_message_allocator.html"> 64</a></span> <span class="keyword">class </span><a class="code" href="classgrpc_1_1experimental_1_1_message_allocator.html">MessageAllocator</a> {</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  <span class="keyword">virtual</span> ~<a class="code" href="classgrpc_1_1experimental_1_1_message_allocator.html">MessageAllocator</a>() = <span class="keywordflow">default</span>;</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  <span class="keyword">virtual</span> <a class="code" href="classgrpc_1_1experimental_1_1_message_holder.html">MessageHolder<RequestT, ResponseT></a>* AllocateMessages() = 0;</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span> };</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span> </div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span> } <span class="comment">// namespace experimental</span></div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span> } <span class="comment">// namespace grpc</span></div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span> </div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span> <span class="preprocessor">#endif // GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H</span></div><div class="ttc" id="classgrpc_1_1experimental_1_1_message_allocator_html"><div class="ttname"><a href="classgrpc_1_1experimental_1_1_message_allocator.html">grpc::experimental::MessageAllocator</a></div><div class="ttdef"><b>Definition:</b> message_allocator.h:64</div></div>
|
|
<div class="ttc" id="classgrpc_1_1experimental_1_1_message_holder_html_a8bed5c98e17cff87b7641d527c84fac3"><div class="ttname"><a href="classgrpc_1_1experimental_1_1_message_holder.html#a8bed5c98e17cff87b7641d527c84fac3">grpc::experimental::MessageHolder::set_response</a></div><div class="ttdeci">void set_response(ResponseT *response)</div><div class="ttdef"><b>Definition:</b> message_allocator.h:51</div></div>
|
|
<div class="ttc" id="classgrpc_1_1experimental_1_1_rpc_allocator_state_html_aa2f076faaed3c8f2b7a113bf38e9c9dd"><div class="ttname"><a href="classgrpc_1_1experimental_1_1_rpc_allocator_state.html#aa2f076faaed3c8f2b7a113bf38e9c9dd">grpc::experimental::RpcAllocatorState::~RpcAllocatorState</a></div><div class="ttdeci">virtual ~RpcAllocatorState()=default</div></div>
|
|
<div class="ttc" id="classgrpc_1_1experimental_1_1_message_holder_html_a169fb5a4b742b8a55b04fc9dec54aecb"><div class="ttname"><a href="classgrpc_1_1experimental_1_1_message_holder.html#a169fb5a4b742b8a55b04fc9dec54aecb">grpc::experimental::MessageHolder::response</a></div><div class="ttdeci">ResponseT * response()</div><div class="ttdef"><b>Definition:</b> message_allocator.h:47</div></div>
|
|
<div class="ttc" id="classgrpc_1_1experimental_1_1_message_holder_html_af8dfca1336d734a4f3406327d35e22b7"><div class="ttname"><a href="classgrpc_1_1experimental_1_1_message_holder.html#af8dfca1336d734a4f3406327d35e22b7">grpc::experimental::MessageHolder::request</a></div><div class="ttdeci">RequestT * request()</div><div class="ttdef"><b>Definition:</b> message_allocator.h:46</div></div>
|
|
<div class="ttc" id="classgrpc_1_1experimental_1_1_message_holder_html_a3c627621eb7f90440e0fae41ebdbae10"><div class="ttname"><a href="classgrpc_1_1experimental_1_1_message_holder.html#a3c627621eb7f90440e0fae41ebdbae10">grpc::experimental::MessageHolder::set_request</a></div><div class="ttdeci">void set_request(RequestT *request)</div><div class="ttdef"><b>Definition:</b> message_allocator.h:50</div></div>
|
|
<div class="ttc" id="namespacegrpc_html"><div class="ttname"><a href="namespacegrpc.html">grpc</a></div><div class="ttdoc">This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...</div><div class="ttdef"><b>Definition:</b> alarm.h:24</div></div>
|
|
<div class="ttc" id="classgrpc_1_1experimental_1_1_message_holder_html"><div class="ttname"><a href="classgrpc_1_1experimental_1_1_message_holder.html">grpc::experimental::MessageHolder</a></div><div class="ttdef"><b>Definition:</b> message_allocator.h:40</div></div>
|
|
<div class="ttc" id="classgrpc_1_1experimental_1_1_rpc_allocator_state_html_a75dc7544cb4886b53fcc5a7c98e525f5"><div class="ttname"><a href="classgrpc_1_1experimental_1_1_rpc_allocator_state.html#a75dc7544cb4886b53fcc5a7c98e525f5">grpc::experimental::RpcAllocatorState::FreeRequest</a></div><div class="ttdeci">virtual void FreeRequest()</div><div class="ttdef"><b>Definition:</b> message_allocator.h:33</div></div>
|
|
<div class="ttc" id="classgrpc_1_1experimental_1_1_rpc_allocator_state_html"><div class="ttname"><a href="classgrpc_1_1experimental_1_1_rpc_allocator_state.html">grpc::experimental::RpcAllocatorState</a></div><div class="ttdef"><b>Definition:</b> message_allocator.h:27</div></div>
|
|
</div><!-- fragment --></div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated on Wed Jul 3 2019 14:51:27 for GRPC C++ by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.13
|
|
</small></address>
|
|
</body>
|
|
</html>
|