Skip to content

Commit 971c235

Browse files
Remove unneeded intermediate async for Ethernet (#1864)
Remove the always pending worker whose job it was to fire another async worker after a timeout.
1 parent abd3547 commit 971c235

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

libraries/lwIP_Ethernet/src/LwipEthernet.cpp

+3-11
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ bool __ethernetContextInitted = false;
3131

3232
// Async context that pumps the ethernet controllers
3333
static async_context_threadsafe_background_t lwip_ethernet_async_context_threadsafe_background;
34-
static async_when_pending_worker_t always_pending_update_timeout_worker;
3534
static async_at_time_worker_t ethernet_timeout_worker;
3635

3736
static async_context_t *_context = nullptr;
@@ -129,8 +128,9 @@ static async_context_t *lwip_ethernet_init_default_async_context(void) {
129128
return NULL;
130129
}
131130

131+
static uint32_t _pollingPeriod = 20;
132132
// This will only be called under the protection of the async context mutex, so no re-entrancy checks needed
133-
static void ethernet_timeout_reached(__unused async_context_t *context, __unused async_at_time_worker_t *worker) {
133+
static void ethernet_timeout_reached(async_context_t *context, __unused async_at_time_worker_t *worker) {
134134
assert(worker == &ethernet_timeout_worker);
135135
for (auto handlePacket : _handlePacketList) {
136136
handlePacket.second();
@@ -142,12 +142,6 @@ static void ethernet_timeout_reached(__unused async_context_t *context, __unused
142142
#else
143143
sys_check_timeouts();
144144
#endif
145-
}
146-
147-
static uint32_t _pollingPeriod = 20;
148-
static void update_next_timeout(async_context_t *context, async_when_pending_worker_t *worker) {
149-
assert(worker == &always_pending_update_timeout_worker);
150-
worker->work_pending = true;
151145
async_context_add_at_time_worker_in_ms(context, &ethernet_timeout_worker, _pollingPeriod);
152146
}
153147

@@ -164,10 +158,8 @@ void __startEthernetContext() {
164158
#else
165159
_context = lwip_ethernet_init_default_async_context();
166160
#endif
167-
always_pending_update_timeout_worker.work_pending = true;
168-
always_pending_update_timeout_worker.do_work = update_next_timeout;
169161
ethernet_timeout_worker.do_work = ethernet_timeout_reached;
170-
async_context_add_when_pending_worker(_context, &always_pending_update_timeout_worker);
162+
async_context_add_at_time_worker_in_ms(_context, &ethernet_timeout_worker, _pollingPeriod);
171163
__ethernetContextInitted = true;
172164
}
173165

0 commit comments

Comments
 (0)