Adopt Callback class in NetworkSocketAPI

Christopher Haster 2016-05-16 11:48:09 -05:00
parent e1c42a3afc
commit dd6a24b76d
2 changed files with 8 additions and 8 deletions

View File

@ -148,7 +148,7 @@ int Socket::getsockopt(int level, int optname, void *optval, unsigned *optlen)
} }
void Socket::attach(FunctionPointer callback) void Socket::attach(Callback<void()> callback)
{ {
_lock.lock(); _lock.lock();

View File

@ -145,9 +145,9 @@ public:
* The callback may be called in an interrupt context and should not * The callback may be called in an interrupt context and should not
* perform expensive operations such as recv/send calls. * perform expensive operations such as recv/send calls.
* *
* @param callback Function to call on state change * @param func Function to call on state change
*/ */
void attach(FunctionPointer callback); void attach(Callback<void()> func);
/** Register a callback on state change of the socket /** Register a callback on state change of the socket
* *
@ -158,12 +158,12 @@ public:
* The callback may be called in an interrupt context and should not * The callback may be called in an interrupt context and should not
* perform expensive operations such as recv/send calls. * perform expensive operations such as recv/send calls.
* *
* @param tptr Pointer to object to call method on * @param obj Pointer to object to call method on
* @param mptr Method to call on state change * @param method Method to call on state change
*/ */
template <typename T, typename M> template <typename T, typename M>
void attach(T *tptr, M mptr) { void attach(T *obj, M method) {
attach(FunctionPointer(tptr, mptr)); attach(Callback<void()>(obj, method));
} }
protected: protected:
@ -176,7 +176,7 @@ protected:
NetworkStack *_iface; NetworkStack *_iface;
void *_socket; void *_socket;
uint32_t _timeout; uint32_t _timeout;
FunctionPointer _callback; Callback<void()> _callback;
rtos::Mutex _lock; rtos::Mutex _lock;
}; };