Skip to content

Commit 3fa70cf

Browse files
andy31415mkardous-silabs
andauthoredMay 2, 2024
Replace DispatchSessionEvent with NotifySessionHang on sessions. (#33259)
* Replace `Dispatch event` with `NotifySessionHang` on sessions. Only a single event was ever dispatched and the pattern of passing in pointers to member methods was not used anywhere else and resulted in fairly unique code. Spelling out the `NotifySessionHang` explicitly seems to simplify maintainability. * Update src/transport/Session.h Co-authored-by: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> --------- Co-authored-by: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com>
1 parent 16b8076 commit 3fa70cf

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed
 

‎src/messaging/ExchangeContext.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ void ExchangeContext::NotifyResponseTimeout(bool aCloseIfNeeded)
485485
{
486486
mSession->AsSecureSession()->MarkAsDefunct();
487487
}
488-
mSession->DispatchSessionEvent(&SessionDelegate::OnSessionHang);
488+
mSession->NotifySessionHang();
489489
}
490490
}
491491

‎src/messaging/ReliableMessageMgr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void ReliableMessageMgr::ExecuteActions()
158158
{
159159
session->AsSecureSession()->MarkAsDefunct();
160160
}
161-
session->DispatchSessionEvent(&SessionDelegate::OnSessionHang);
161+
session->NotifySessionHang();
162162
}
163163

164164
// Do not StartTimer, we will schedule the timer at the end of the timer handler.

‎src/transport/Session.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ class SessionHolder : public IntrusiveListNodeBase<>
114114

115115
Transport::Session * operator->() const { return &mSession.Value().Get(); }
116116

117-
// There is not delegate, nothing to do here
118-
virtual void DispatchSessionEvent(SessionDelegate::Event event) {}
117+
// There is no delegate, nothing to do here
118+
virtual void OnSessionHang() {}
119119

120120
protected:
121121
// Helper for use by the Grab methods.
@@ -147,7 +147,7 @@ class SessionHolderWithDelegate : public SessionHolder
147147
SessionHolder::ShiftToSession(session);
148148
}
149149

150-
void DispatchSessionEvent(SessionDelegate::Event event) override { (mDelegate.*event)(); }
150+
void OnSessionHang() override { mDelegate.OnSessionHang(); }
151151

152152
private:
153153
SessionDelegate & mDelegate;
@@ -237,15 +237,15 @@ class Session
237237
void SetTCPConnection(ActiveTCPConnectionState * conn) { mTCPConnection = conn; }
238238
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
239239

240-
void DispatchSessionEvent(SessionDelegate::Event event)
240+
void NotifySessionHang()
241241
{
242242
// Holders might remove themselves when notified.
243243
auto holder = mHolders.begin();
244244
while (holder != mHolders.end())
245245
{
246246
auto cur = holder;
247247
++holder;
248-
cur->DispatchSessionEvent(event);
248+
cur->OnSessionHang();
249249
}
250250
}
251251

‎src/transport/SessionDelegate.h

-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ class DLL_EXPORT SessionDelegate
5151
*/
5252
virtual NewSessionHandlingPolicy GetNewSessionHandlingPolicy() { return NewSessionHandlingPolicy::kShiftToNewSession; }
5353

54-
using Event = void (SessionDelegate::*)();
55-
5654
/**
5755
* @brief
5856
* Called when a session is releasing. Callees SHALL NOT make synchronous calls into SessionManager to allocate a new session.

0 commit comments

Comments
 (0)