170c820401677ca251ad09ac64cc23c760764e75dElliott Hughes/* 270c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * Copyright (C) 2011 The Android Open Source Project 370c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * 470c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 570c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * you may not use this file except in compliance with the License. 670c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * You may obtain a copy of the License at 770c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * 870c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 970c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * 1070c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * Unless required by applicable law or agreed to in writing, software 1170c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 1270c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1370c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * See the License for the specific language governing permissions and 1470c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * limitations under the License. 1570c820401677ca251ad09ac64cc23c760764e75dElliott Hughes */ 1670c820401677ca251ad09ac64cc23c760764e75dElliott Hughes 175d930cadc8f62aee5f18e7921296fe66a54f18abElliott Hughespackage android.system; 1870c820401677ca251ad09ac64cc23c760764e75dElliott Hughes 1970c820401677ca251ad09ac64cc23c760764e75dElliott Hughesimport java.io.FileDescriptor; 20fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughesimport libcore.util.Objects; 2170c820401677ca251ad09ac64cc23c760764e75dElliott Hughes 2270c820401677ca251ad09ac64cc23c760764e75dElliott Hughes/** 2334721e8e0051258e87848bae25baf50722b4c76aElliott Hughes * Used as an in/out parameter to {@link Os#poll}. 24c42b3c9036c6b9fa4d66ad0efa2d9b37a5c5bbf5Neil Fuller * Corresponds to C's {@code struct pollfd} from {@code <poll.h>}. 2570c820401677ca251ad09ac64cc23c760764e75dElliott Hughes */ 2670c820401677ca251ad09ac64cc23c760764e75dElliott Hughespublic final class StructPollfd { 27fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes /** The file descriptor to poll. */ 28fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes public FileDescriptor fd; 2970c820401677ca251ad09ac64cc23c760764e75dElliott Hughes 30fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes /** 31fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes * The events we're interested in. POLLIN corresponds to being in select(2)'s read fd set, 32fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes * POLLOUT to the write fd set. 33fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes */ 34fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes public short events; 3570c820401677ca251ad09ac64cc23c760764e75dElliott Hughes 36fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes /** The events that actually happened. */ 37fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes public short revents; 3870c820401677ca251ad09ac64cc23c760764e75dElliott Hughes 39fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes /** 40fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes * A non-standard extension that lets callers conveniently map back to the object 41fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes * their fd belongs to. This is used by Selector, for example, to associate each 42fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes * FileDescriptor with the corresponding SelectionKey. 43fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes */ 44fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes public Object userData; 4570c820401677ca251ad09ac64cc23c760764e75dElliott Hughes 46fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes @Override public String toString() { 47fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes return Objects.toString(this); 48fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes } 4970c820401677ca251ad09ac64cc23c760764e75dElliott Hughes} 50