Rtos API example

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