Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_poll.h Source File

mbed_poll.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2017-2019 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef MBED_POLL_H
00018 #define MBED_POLL_H
00019 
00020 #define POLLIN         0x0001 ///< Data may be read without blocking
00021 #define POLLOUT        0x0010 ///< Data may be written without blocking
00022 #define POLLERR        0x1000 ///< An error has occurred on the device or stream
00023 #define POLLHUP        0x2000 ///< The device has been disconnected
00024 #define POLLNVAL       0x4000 ///< The specified file handle value is invalid
00025 
00026 namespace mbed {
00027 
00028 class FileHandle;
00029 
00030 /** \addtogroup platform-public-api */
00031 /** @{*/
00032 
00033 /**
00034  * \defgroup platform_poll poll functions
00035  * @{
00036  */
00037 
00038 struct pollfh {
00039     FileHandle *fh;
00040     short events;
00041     short revents;
00042 };
00043 
00044 /** A mechanism to multiplex input/output over a set of file handles(file descriptors).
00045  * For every file handle provided, poll() examines it for any events registered for that particular
00046  * file handle.
00047  *
00048  * @param fhs     an array of PollFh struct carrying a FileHandle and bitmasks of events
00049  * @param nfhs    number of file handles
00050  * @param timeout timer value to timeout or -1 for loop forever
00051  *
00052  * @return number of file handles selected (for which revents is non-zero). 0 if timed out with nothing selected. -1 for error.
00053  */
00054 int poll(pollfh fhs[], unsigned nfhs, int timeout);
00055 
00056 /**@}*/
00057 
00058 /**@}*/
00059 
00060 } // namespace mbed
00061 
00062 #endif //MBED_POLL_H