Skip to content

Commit f87b323

Browse files
committed
Callback updates
* Optimise clearing by adding `nullptr` overload. This overload means `Callback(NULL)` or `Callback(0)` will no longer work; users must use `Callback(nullptr)` or `Callback()`. * Optimise clearing by not clearing storage - increases code size of comparison, but that is extremely rare. * Reduce ROM used by trivial functors - share copy/destroy code. * Config option to force trivial functors - major ROM saving by eliminating the "operations" table. * Config option to eliminate comparison altogether - minor ROM saving by eliminating zero padding. * Conform more to `std::function` API. Remove move stuff More callback work
1 parent 142bb82 commit f87b323

File tree

4 files changed

+569
-251
lines changed

4 files changed

+569
-251
lines changed

features/netsocket/NetworkInterface.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ void NetworkInterface::add_event_listener(mbed::Callback<void(nsapi_event_t, int
151151
attach(mbed::callback(&call_all_event_listeners, this));
152152
}
153153

154+
#if MBED_CONF_PLATFORM_CALLBACK_COMPARABLE
154155
void NetworkInterface::remove_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb)
155156
{
156157
iface_eventlist_t *event_list = get_interface_event_list_head();
@@ -162,6 +163,7 @@ void NetworkInterface::remove_event_listener(mbed::Callback<void(nsapi_event_t,
162163
}
163164
}
164165
}
166+
#endif
165167

166168
NetworkInterface::~NetworkInterface()
167169
{

features/netsocket/NetworkInterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,15 @@ class NetworkInterface: public DNS {
323323
*/
324324
void add_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
325325

326+
#if MBED_CONF_PLATFORM_CALLBACK_COMPARABLE
326327
/** Remove event listener from interface.
327328
*
328329
* Remove previously added callback from the handler list.
329330
*
330331
* @param status_cb The callback to unregister.
331332
*/
332333
void remove_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
334+
#endif
333335

334336
/** Get the connection status.
335337
*

0 commit comments

Comments
 (0)