|
Open Model Railroad Network (OpenMRN)
|
Helper class that allows a select to be asynchronously woken up. More...
#include <OSSelectWakeup.hxx>
Public Member Functions | |
| os_thread_t | main_thread () |
| void | lock_to_thread () |
| Prepares the current thread for asynchronous wakeups. | |
| void | wakeup () |
| Wakes up the select in the locked thread. | |
| void | clear_wakeup () |
| Called from the main thread after being woken up. | |
| int | select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, long long deadline_nsec) |
| Portable call to a select that can be woken up asynchronously from a different thread or an ISR context. | |
Private Attributes | |
| bool | pendingWakeup_ |
| True if there was a wakeup call since the previous select finished. | |
| bool | inSelect_ |
| True during the duration of a select operation. | |
| os_thread_t | thread_ |
| ID of the main thread we are engaged upon. | |
Additional Inherited Members | |
Private Member Functions inherited from Atomic | |
| void | lock () |
| void | unlock () |
Helper class that allows a select to be asynchronously woken up.
Definition at line 75 of file OSSelectWakeup.hxx.
|
inline |
Definition at line 78 of file OSSelectWakeup.hxx.
|
inline |
Definition at line 84 of file OSSelectWakeup.hxx.
|
inline |
Called from the main thread after being woken up.
Enables further wakeup signals to be collected.
Definition at line 154 of file OSSelectWakeup.hxx.
|
inline |
Prepares the current thread for asynchronous wakeups.
Can be called only once.
Definition at line 99 of file OSSelectWakeup.hxx.
|
inline |
Definition at line 92 of file OSSelectWakeup.hxx.
| int OSSelectWakeup::select | ( | int | nfds, |
| fd_set * | readfds, | ||
| fd_set * | writefds, | ||
| fd_set * | exceptfds, | ||
| long long | deadline_nsec | ||
| ) |
Portable call to a select that can be woken up asynchronously from a different thread or an ISR context.
| nfds | is as a regular select call. |
| readfds | is as a regular select call. |
| writefds | is as a regular select call. |
| exceptfds | is as a regular select call. |
| deadline_nsec | is the maximum time to sleep if no fd activity and no wakeup happens. -1 to sleep indefinitely, 0 to return immediately. |
Definition at line 44 of file OSSelectWakeup.cxx.
|
inline |
Wakes up the select in the locked thread.
Definition at line 124 of file OSSelectWakeup.hxx.
|
private |
True during the duration of a select operation.
Definition at line 241 of file OSSelectWakeup.hxx.
|
private |
True if there was a wakeup call since the previous select finished.
Definition at line 239 of file OSSelectWakeup.hxx.
|
private |
ID of the main thread we are engaged upon.
Definition at line 243 of file OSSelectWakeup.hxx.