1 /** @file
2 
3   A brief file description
4 
5   @section license License
6 
7   Licensed to the Apache Software Foundation (ASF) under one
8   or more contributor license agreements.  See the NOTICE file
9   distributed with this work for additional information
10   regarding copyright ownership.  The ASF licenses this file
11   to you under the Apache License, Version 2.0 (the
12   "License"); you may not use this file except in compliance
13   with the License.  You may obtain a copy of the License at
14 
15       http://www.apache.org/licenses/LICENSE-2.0
16 
17   Unless required by applicable law or agreed to in writing, software
18   distributed under the License is distributed on an "AS IS" BASIS,
19   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20   See the License for the specific language governing permissions and
21   limitations under the License.
22  */
23 
24 #pragma once
25 
26 // platform specific wrappers for dealing with I/O completion events
27 // passed into and back from the I/O core.
28 #include "P_UDPIOEvent.h"
29 
30 TS_INLINE Event *
create()31 completionUtil::create()
32 {
33   UDPIOEvent *u = UDPIOEventAllocator.alloc();
34   return u;
35 }
36 TS_INLINE void
destroy(Event * e)37 completionUtil::destroy(Event *e)
38 {
39   ink_assert(e != nullptr);
40   UDPIOEvent *u = (UDPIOEvent *)e;
41   UDPIOEvent::free(u);
42 }
43 TS_INLINE void
setThread(Event * e,EThread * t)44 completionUtil::setThread(Event *e, EThread *t)
45 {
46   UDPIOEvent *u = (UDPIOEvent *)e;
47   u->ethread    = t;
48 }
49 TS_INLINE void
setContinuation(Event * e,Continuation * c)50 completionUtil::setContinuation(Event *e, Continuation *c)
51 {
52   UDPIOEvent *u = (UDPIOEvent *)e;
53   *(Action *)u  = c;
54 }
55 TS_INLINE void *
getHandle(Event * e)56 completionUtil::getHandle(Event *e)
57 {
58   UDPIOEvent *u = (UDPIOEvent *)e;
59   return u->getHandle();
60 }
61 TS_INLINE void
setHandle(Event * e,void * handle)62 completionUtil::setHandle(Event *e, void *handle)
63 {
64   UDPIOEvent *u = (UDPIOEvent *)e;
65   u->setHandle(handle);
66 }
67 TS_INLINE void
setInfo(Event * e,int fd,const Ptr<IOBufferBlock> & buf,int actual,int errno_)68 completionUtil::setInfo(Event *e, int fd, const Ptr<IOBufferBlock> &buf, int actual, int errno_)
69 {
70   UDPIOEvent *u = (UDPIOEvent *)e;
71   u->setInfo(fd, buf, actual, errno_);
72 }
73 TS_INLINE void
setInfo(Event * e,int fd,struct msghdr * msg,int actual,int errno_)74 completionUtil::setInfo(Event *e, int fd, struct msghdr *msg, int actual, int errno_)
75 {
76   UDPIOEvent *u = (UDPIOEvent *)e;
77   u->setInfo(fd, msg, actual, errno_);
78 }
79 TS_INLINE int
getBytesTransferred(Event * e)80 completionUtil::getBytesTransferred(Event *e)
81 {
82   UDPIOEvent *u = (UDPIOEvent *)e;
83   return u->getBytesTransferred();
84 }
85 TS_INLINE IOBufferBlock *
getIOBufferBlock(Event * e)86 completionUtil::getIOBufferBlock(Event *e)
87 {
88   UDPIOEvent *u = (UDPIOEvent *)e;
89   return u->getIOBufferBlock();
90 }
91 TS_INLINE Continuation *
getContinuation(Event * e)92 completionUtil::getContinuation(Event *e)
93 {
94   UDPIOEvent *u = (UDPIOEvent *)e;
95   return u->getContinuation();
96 }
97 TS_INLINE int
getError(Event * e)98 completionUtil::getError(Event *e)
99 {
100   UDPIOEvent *u = (UDPIOEvent *)e;
101   return u->getError();
102 }
103