Skip to content

Commit dd6a24b

Browse files
committed
Adopt Callback class in NetworkSocketAPI
1 parent e1c42a3 commit dd6a24b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

net/NetworkSocketAPI/Socket.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ int Socket::getsockopt(int level, int optname, void *optval, unsigned *optlen)
148148

149149
}
150150

151-
void Socket::attach(FunctionPointer callback)
151+
void Socket::attach(Callback<void()> callback)
152152
{
153153
_lock.lock();
154154

net/NetworkSocketAPI/Socket.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ class Socket {
145145
* The callback may be called in an interrupt context and should not
146146
* perform expensive operations such as recv/send calls.
147147
*
148-
* @param callback Function to call on state change
148+
* @param func Function to call on state change
149149
*/
150-
void attach(FunctionPointer callback);
150+
void attach(Callback<void()> func);
151151

152152
/** Register a callback on state change of the socket
153153
*
@@ -158,12 +158,12 @@ class Socket {
158158
* The callback may be called in an interrupt context and should not
159159
* perform expensive operations such as recv/send calls.
160160
*
161-
* @param tptr Pointer to object to call method on
162-
* @param mptr Method to call on state change
161+
* @param obj Pointer to object to call method on
162+
* @param method Method to call on state change
163163
*/
164164
template <typename T, typename M>
165-
void attach(T *tptr, M mptr) {
166-
attach(FunctionPointer(tptr, mptr));
165+
void attach(T *obj, M method) {
166+
attach(Callback<void()>(obj, method));
167167
}
168168

169169
protected:
@@ -176,7 +176,7 @@ class Socket {
176176
NetworkStack *_iface;
177177
void *_socket;
178178
uint32_t _timeout;
179-
FunctionPointer _callback;
179+
Callback<void()> _callback;
180180
rtos::Mutex _lock;
181181
};
182182

0 commit comments

Comments
 (0)