Skip to content

Commit d4e686b

Browse files
committed
nsapi: Renamed attach -> sigio to decrease confusion on its behaviour
1 parent 21b91c7 commit d4e686b

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

features/netsocket/Socket.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,14 @@ nsapi_error_t Socket::getsockopt(int level, int optname, void *optval, unsigned
149149

150150
}
151151

152-
void Socket::attach(Callback<void()> callback)
152+
void Socket::sigio(Callback<void()> callback)
153153
{
154154
_lock.lock();
155-
156155
_callback = callback;
157-
158156
_lock.unlock();
159157
}
158+
159+
void Socket::attach(Callback<void()> callback)
160+
{
161+
sigio(callback);
162+
}

features/netsocket/Socket.h

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,22 +163,30 @@ class Socket {
163163
* The callback may be called in an interrupt context and should not
164164
* perform expensive operations such as recv/send calls.
165165
*
166+
* Note! This is not intended as a replacement for a poll or attach-like
167+
* asynchronous api, but rather as a building block for constructing
168+
* such functionality. The exact timing of when the registered function
169+
* is called is not guaranteed and susceptible to change.
170+
*
166171
* @param func Function to call on state change
167172
*/
168-
void attach(mbed::Callback<void()> func);
173+
void sigio(mbed::Callback<void()> func);
169174

170175
/** Register a callback on state change of the socket
171176
*
172-
* The specified callback will be called on state changes such as when
173-
* the socket can recv/send/accept successfully and on when an error
174-
* occurs. The callback may also be called spuriously without reason.
175-
*
176-
* The callback may be called in an interrupt context and should not
177-
* perform expensive operations such as recv/send calls.
178-
*
179-
* @param obj Pointer to object to call method on
180-
* @param method Method to call on state change
177+
* @see Socket::sigio
178+
* @deprecated
179+
* The behaviour of Socket::attach differs from other attach functions in
180+
* mbed OS and has been known to cause confusion. Replaced by Socket::sigio.
181+
*/
182+
MBED_DEPRECATED_SINCE("mbed-os-5.4",
183+
"The behaviour of Socket::attach differs from other attach functions in "
184+
"mbed OS and has been known to cause confusion. Replaced by Socket::sigio.")
185+
void attach(mbed::Callback<void()> func);
186+
187+
/** Register a callback on state change of the socket
181188
*
189+
* @see Socket::sigio
182190
* @deprecated
183191
* The attach function does not support cv-qualifiers. Replaced by
184192
* attach(callback(obj, method)).

0 commit comments

Comments
 (0)