mirror of https://github.com/ARMmbed/mbed-os.git
Pull request feedback fix: add poll support to multiplexer
parent
0c8c41ff5f
commit
cd486f2624
|
@ -1238,4 +1238,16 @@ ssize_t Mux::user_data_rx(void* buffer, size_t size)
|
|||
}
|
||||
|
||||
|
||||
short Mux::poll()
|
||||
{
|
||||
_mutex.lock();
|
||||
|
||||
const bool writable = (_tx_context.tx_state == TX_IDLE);
|
||||
const bool readable = (_rx_context.rx_state == RX_SUSPEND);
|
||||
|
||||
_mutex.unlock();
|
||||
|
||||
return ((readable ? POLLIN : 0) | (writable ? POLLOUT : 0));
|
||||
}
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -72,6 +72,18 @@ public:
|
|||
*/
|
||||
virtual ssize_t read(void *buffer, size_t size);
|
||||
|
||||
/** Check for poll event flags
|
||||
*
|
||||
* The input parameter can be used or ignored - could always return all events, or could check just the events
|
||||
* listed in events.
|
||||
*
|
||||
* Call is non-blocking - returns instantaneous state of events.
|
||||
*
|
||||
* @param events Bitmask of poll events we're interested in - POLLIN/POLLOUT etc.
|
||||
* @return Bitmask of poll events that have occurred.
|
||||
*/
|
||||
virtual short poll(short events) const;
|
||||
|
||||
/** Not supported by the implementation. */
|
||||
virtual off_t seek(off_t offset, int whence = SEEK_SET);
|
||||
|
||||
|
@ -434,6 +446,12 @@ private:
|
|||
*/
|
||||
static ssize_t user_data_rx(void* buffer, size_t size);
|
||||
|
||||
/** Check for poll event flags
|
||||
*
|
||||
* @return Bitmask of poll events that have occurred - POLLIN/POLLOUT.
|
||||
*/
|
||||
static short poll();
|
||||
|
||||
/** Clear TX callback pending bit.
|
||||
*
|
||||
* @param bit Bit to clear.
|
||||
|
|
|
@ -31,6 +31,12 @@ ssize_t MuxDataService::read(void *buffer, size_t size)
|
|||
}
|
||||
|
||||
|
||||
short MuxDataService::poll(short events) const
|
||||
{
|
||||
return Mux::poll();
|
||||
}
|
||||
|
||||
|
||||
off_t MuxDataService::seek(off_t offset, int whence)
|
||||
{
|
||||
MBED_ASSERT(false);
|
||||
|
|
Loading…
Reference in New Issue