Skip to content

Commit 90dbc21

Browse files
cmcfarlenChris McFarlen
andauthored
Remove eventsystem Inline.cc and cleanup private headers. (#12581)
* Remove eventsystem Inline.cc and cleanup private headers. * include EThread to get this_ethread * Fix include in RecProcess.cc * Remove I_VIO_h * restore DELAY_FOR_RETRY --------- Co-authored-by: Chris McFarlen <[email protected]>
1 parent f1247af commit 90dbc21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1702
-2060
lines changed

include/iocore/eventsystem/EThread.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,29 @@ operator new(size_t, ink_dummy_for_new *p)
710710
}
711711
#define ETHREAD_GET_PTR(thread, offset) ((void *)((char *)(thread) + (offset)))
712712

713-
extern EThread *this_ethread();
713+
inline EThread *
714+
this_ethread()
715+
{
716+
return EThread::this_ethread_ptr;
717+
}
718+
719+
inline EThread *
720+
this_event_thread()
721+
{
722+
EThread *ethread = this_ethread();
723+
if (ethread != nullptr && ethread->tt == REGULAR) {
724+
return ethread;
725+
} else {
726+
return nullptr;
727+
}
728+
}
729+
730+
inline void
731+
EThread::free_event(Event *e)
732+
{
733+
ink_assert(!e->in_the_priority_queue && !e->in_the_prot_queue);
734+
e->mutex = nullptr;
735+
EVENT_FREE(e, eventAllocator, this);
736+
}
714737

715738
extern int thread_max_heartbeat_mseconds;

include/iocore/eventsystem/Event.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,18 @@ class Event : public Action
228228

229229
// Private
230230

231-
Event();
231+
Event() : in_the_prot_queue(false), in_the_priority_queue(false), immediate(false), globally_allocated(true), in_heap(false) {}
232232

233-
Event *init(Continuation *c, ink_hrtime atimeout_at = 0, ink_hrtime aperiod = 0);
233+
Event *
234+
init(Continuation *c, ink_hrtime atimeout_at = 0, ink_hrtime aperiod = 0)
235+
{
236+
continuation = c;
237+
timeout_at = atimeout_at;
238+
period = aperiod;
239+
immediate = !period && !atimeout_at;
240+
cancelled = false;
241+
return this;
242+
}
234243

235244
#ifdef ENABLE_TIME_TRACE
236245
ink_hrtime start_time;
@@ -282,6 +291,13 @@ class Event : public Action
282291
//
283292
extern ClassAllocator<Event> eventAllocator;
284293

294+
inline void
295+
Event::free()
296+
{
297+
mutex = nullptr;
298+
eventAllocator.free(this);
299+
}
300+
285301
#define EVENT_ALLOC(_a, _t) THREAD_ALLOC(_a, _t)
286302
#define EVENT_FREE(_p, _a, _t) \
287303
_p->mutex = nullptr; \

include/iocore/eventsystem/Freer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ template <class C> struct DeleterContinuation : public Continuation {
5252
// 1. Make sure to schedule a delete on an ET_TASK thread
5353
// 2. Delay the delete (this should be used sparingly)
5454
template <class C>
55-
TS_INLINE void
55+
void
5656
new_Deleter(C *ap, ink_hrtime t)
5757
{
5858
if (t > 0) {
@@ -78,7 +78,7 @@ template <class C> struct FreeCallContinuation : public Continuation {
7878
};
7979

8080
template <class C>
81-
TS_INLINE void
81+
void
8282
new_FreeCaller(C *ap, ink_hrtime t)
8383
{
8484
eventProcessor.schedule_in(new FreeCallContinuation<C>(ap), t, ET_TASK);
@@ -103,7 +103,7 @@ struct FreerContinuation : public Continuation {
103103
explicit FreerContinuation(void *ap) : Continuation(nullptr), p(ap) { SET_HANDLER(&FreerContinuation::dieEvent); }
104104
};
105105

106-
TS_INLINE void
106+
inline void
107107
new_Freer(void *ap, ink_hrtime t)
108108
{
109109
eventProcessor.schedule_in(new FreerContinuation(ap), t, ET_TASK);
@@ -128,7 +128,7 @@ template <class C> struct DereferContinuation : public Continuation {
128128
};
129129

130130
template <class C>
131-
TS_INLINE void
131+
void
132132
new_Derefer(C *ap, ink_hrtime t)
133133
{
134134
eventProcessor.schedule_in(new DereferContinuation<C>(ap), t, ET_TASK);

include/iocore/eventsystem/IOBuffer.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,3 +1514,44 @@ IOBufferChain::iterator::operator->() const
15141514
{
15151515
return _b;
15161516
}
1517+
1518+
//////////////////////////////////////////////////////////////
1519+
//
1520+
// returns 0 for DEFAULT_BUFFER_BASE_SIZE,
1521+
// +1 for each power of 2
1522+
//
1523+
//////////////////////////////////////////////////////////////
1524+
inline int64_t
1525+
buffer_size_to_index(int64_t size, int64_t max)
1526+
{
1527+
int64_t r = max;
1528+
1529+
while (r && BUFFER_SIZE_FOR_INDEX(r - 1) >= size) {
1530+
r--;
1531+
}
1532+
return r;
1533+
}
1534+
1535+
inline int64_t
1536+
iobuffer_size_to_index(int64_t size, int64_t max)
1537+
{
1538+
if (size > BUFFER_SIZE_FOR_INDEX(max)) {
1539+
return BUFFER_SIZE_INDEX_FOR_XMALLOC_SIZE(size);
1540+
}
1541+
return buffer_size_to_index(size, max);
1542+
}
1543+
1544+
inline int64_t
1545+
index_to_buffer_size(int64_t idx)
1546+
{
1547+
if (BUFFER_SIZE_INDEX_IS_FAST_ALLOCATED(idx)) {
1548+
return BUFFER_SIZE_FOR_INDEX(idx);
1549+
} else if (BUFFER_SIZE_INDEX_IS_XMALLOCED(idx)) {
1550+
return BUFFER_SIZE_FOR_XMALLOC(idx);
1551+
// coverity[dead_error_condition]
1552+
} else if (BUFFER_SIZE_INDEX_IS_CONSTANT(idx)) {
1553+
return BUFFER_SIZE_FOR_CONSTANT(idx);
1554+
}
1555+
// coverity[dead_error_line]
1556+
return 0;
1557+
}

include/iocore/eventsystem/ProtectedQueue.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,53 @@ struct ProtectedQueue {
5252

5353
ProtectedQueue();
5454
};
55+
56+
inline ProtectedQueue::ProtectedQueue()
57+
{
58+
Event e;
59+
ink_mutex_init(&lock);
60+
ink_atomiclist_init(&al, "ProtectedQueue", (char *)&e.link.next - (char *)&e);
61+
ink_cond_init(&might_have_data);
62+
}
63+
64+
inline void
65+
ProtectedQueue::signal()
66+
{
67+
// Need to get the lock before you can signal the thread
68+
ink_mutex_acquire(&lock);
69+
ink_cond_signal(&might_have_data);
70+
ink_mutex_release(&lock);
71+
}
72+
73+
inline int
74+
ProtectedQueue::try_signal()
75+
{
76+
// Need to get the lock before you can signal the thread
77+
if (ink_mutex_try_acquire(&lock)) {
78+
ink_cond_signal(&might_have_data);
79+
ink_mutex_release(&lock);
80+
return 1;
81+
} else {
82+
return 0;
83+
}
84+
}
85+
86+
// Called from the same thread (don't need to signal)
87+
inline void
88+
ProtectedQueue::enqueue_local(Event *e)
89+
{
90+
ink_assert(!e->in_the_prot_queue && !e->in_the_priority_queue);
91+
e->in_the_prot_queue = 1;
92+
localQueue.enqueue(e);
93+
}
94+
95+
inline Event *
96+
ProtectedQueue::dequeue_local()
97+
{
98+
Event *e = localQueue.dequeue();
99+
if (e) {
100+
ink_assert(e->in_the_prot_queue);
101+
e->in_the_prot_queue = 0;
102+
}
103+
return e;
104+
}

include/iocore/eventsystem/Thread.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ class Thread
107107
*/
108108
Ptr<ProxyMutex> mutex;
109109

110-
virtual void set_specific() = 0;
110+
virtual void
111+
set_specific()
112+
{
113+
this_thread_ptr = this;
114+
}
111115

112116
static thread_local Thread *this_thread_ptr;
113117

@@ -170,4 +174,8 @@ class Thread
170174
Thread();
171175
};
172176

173-
extern Thread *this_thread();
177+
inline Thread *
178+
this_thread()
179+
{
180+
return Thread::this_thread_ptr;
181+
}

include/iocore/eventsystem/VConnection.h

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
#include "tscore/PluginUserArgs.h"
2929
#include "iocore/eventsystem/EventSystem.h"
3030

31-
#if !defined(I_VIO_h)
32-
#error "include VIO.h"
33-
#endif
34-
3531
//
3632
// Data Types
3733
//
@@ -145,7 +141,7 @@ typedef struct tsapi_vio *TSVIO;
145141
class VConnection : public Continuation
146142
{
147143
public:
148-
~VConnection() override;
144+
~VConnection() override {}
149145

150146
/**
151147
Read data from the VConnection.
@@ -306,17 +302,28 @@ class VConnection : public Continuation
306302
*/
307303
virtual void do_io_shutdown(ShutdownHowTo_t howto) = 0;
308304

309-
explicit VConnection(ProxyMutex *aMutex);
310-
explicit VConnection(Ptr<ProxyMutex> &aMutex);
305+
explicit VConnection(ProxyMutex *aMutex) : Continuation(aMutex), lerrno(0) { SET_HANDLER(nullptr); }
306+
explicit VConnection(Ptr<ProxyMutex> &aMutex) : Continuation(aMutex), lerrno(0) { SET_HANDLER(nullptr); }
311307

312308
// Private
313309
// Set continuation on a given vio. The public interface
314310
// is through VIO::set_continuation()
315-
virtual void set_continuation(VIO *vio, Continuation *cont);
311+
virtual void
312+
set_continuation(VIO *, Continuation *)
313+
{
314+
}
316315

317316
// Reenable a given vio. The public interface is through VIO::reenable
318-
virtual void reenable(VIO *vio);
319-
virtual void reenable_re(VIO *vio);
317+
virtual void
318+
reenable(VIO *)
319+
{
320+
}
321+
322+
virtual void
323+
reenable_re(VIO *vio)
324+
{
325+
reenable(vio);
326+
}
320327

321328
/**
322329
Convenience function to retrieve information from VConnection.
@@ -411,3 +418,32 @@ struct DummyVConnection : public VConnection, public PluginUserArgs<TS_USER_ARGS
411418

412419
explicit DummyVConnection(ProxyMutex *m) : VConnection(m) {}
413420
};
421+
422+
inline const char *
423+
get_vc_event_name(int event)
424+
{
425+
switch (event) {
426+
default:
427+
return "unknown event";
428+
case VC_EVENT_NONE:
429+
return "VC_EVENT_NONE";
430+
case VC_EVENT_IMMEDIATE:
431+
return "VC_EVENT_IMMEDIATE";
432+
case VC_EVENT_READ_READY:
433+
return "VC_EVENT_READ_READY";
434+
case VC_EVENT_WRITE_READY:
435+
return "VC_EVENT_WRITE_READY";
436+
case VC_EVENT_READ_COMPLETE:
437+
return "VC_EVENT_READ_COMPLETE";
438+
case VC_EVENT_WRITE_COMPLETE:
439+
return "VC_EVENT_WRITE_COMPLETE";
440+
case VC_EVENT_EOS:
441+
return "VC_EVENT_EOS";
442+
case VC_EVENT_ERROR:
443+
return "VC_EVENT_ERROR";
444+
case VC_EVENT_INACTIVITY_TIMEOUT:
445+
return "VC_EVENT_INACTIVITY_TIMEOUT";
446+
case VC_EVENT_ACTIVE_TIMEOUT:
447+
return "VC_EVENT_ACTIVE_TIMEOUT";
448+
}
449+
}

0 commit comments

Comments
 (0)