Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nsapi: Rename attach -> sigio to decrease confusion on its behaviour #3784

Merged
merged 1 commit into from
Feb 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions features/netsocket/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,14 @@ nsapi_error_t Socket::getsockopt(int level, int optname, void *optval, unsigned

}

void Socket::attach(Callback<void()> callback)
void Socket::sigio(Callback<void()> callback)
{
_lock.lock();

_callback = callback;

_lock.unlock();
}

void Socket::attach(Callback<void()> callback)
{
sigio(callback);
}
28 changes: 18 additions & 10 deletions features/netsocket/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,30 @@ class Socket {
* The callback may be called in an interrupt context and should not
* perform expensive operations such as recv/send calls.
*
* Note! This is not intended as a replacement for a poll or attach-like
* asynchronous api, but rather as a building block for constructing
* such functionality. The exact timing of when the registered function
* is called is not guaranteed and susceptible to change.
*
* @param func Function to call on state change
*/
void attach(mbed::Callback<void()> func);
void sigio(mbed::Callback<void()> func);

/** Register a callback on state change of the socket
*
* The specified callback will be called on state changes such as when
* the socket can recv/send/accept successfully and on when an error
* occurs. The callback may also be called spuriously without reason.
*
* The callback may be called in an interrupt context and should not
* perform expensive operations such as recv/send calls.
*
* @param obj Pointer to object to call method on
* @param method Method to call on state change
* @see Socket::sigio
* @deprecated
* The behaviour of Socket::attach differs from other attach functions in
* mbed OS and has been known to cause confusion. Replaced by Socket::sigio.
*/
MBED_DEPRECATED_SINCE("mbed-os-5.4",
"The behaviour of Socket::attach differs from other attach functions in "
"mbed OS and has been known to cause confusion. Replaced by Socket::sigio.")
void attach(mbed::Callback<void()> func);

/** Register a callback on state change of the socket
*
* @see Socket::sigio
* @deprecated
* The attach function does not support cv-qualifiers. Replaced by
* attach(callback(obj, method)).
Expand Down