StructPollfd.java revision 5d930cadc8f62aee5f18e7921296fe66a54f18ab
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;
2070c820401677ca251ad09ac64cc23c760764e75dElliott Hughes
2170c820401677ca251ad09ac64cc23c760764e75dElliott Hughes/**
2270c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * Corresponds to C's {@code struct pollfd} from
2370c820401677ca251ad09ac64cc23c760764e75dElliott Hughes * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/poll.h.html">&lt;poll.h&gt;</a>
245d930cadc8f62aee5f18e7921296fe66a54f18abElliott Hughes *
255d930cadc8f62aee5f18e7921296fe66a54f18abElliott Hughes * @hide
2670c820401677ca251ad09ac64cc23c760764e75dElliott Hughes */
2770c820401677ca251ad09ac64cc23c760764e75dElliott Hughespublic final class StructPollfd {
2870c820401677ca251ad09ac64cc23c760764e75dElliott Hughes    /** The file descriptor to poll. */
2970c820401677ca251ad09ac64cc23c760764e75dElliott Hughes    public FileDescriptor fd;
3070c820401677ca251ad09ac64cc23c760764e75dElliott Hughes
3170c820401677ca251ad09ac64cc23c760764e75dElliott Hughes    /**
3270c820401677ca251ad09ac64cc23c760764e75dElliott Hughes     * The events we're interested in. POLLIN corresponds to being in select(2)'s read fd set,
3370c820401677ca251ad09ac64cc23c760764e75dElliott Hughes     * POLLOUT to the write fd set.
3470c820401677ca251ad09ac64cc23c760764e75dElliott Hughes     */
3570c820401677ca251ad09ac64cc23c760764e75dElliott Hughes    public short events;
3670c820401677ca251ad09ac64cc23c760764e75dElliott Hughes
3770c820401677ca251ad09ac64cc23c760764e75dElliott Hughes    /** The events that actually happened. */
3870c820401677ca251ad09ac64cc23c760764e75dElliott Hughes    public short revents;
3970c820401677ca251ad09ac64cc23c760764e75dElliott Hughes
4070c820401677ca251ad09ac64cc23c760764e75dElliott Hughes    /**
4170c820401677ca251ad09ac64cc23c760764e75dElliott Hughes     * A non-standard extension that lets callers conveniently map back to the object
4270c820401677ca251ad09ac64cc23c760764e75dElliott Hughes     * their fd belongs to. This is used by Selector, for example, to associate each
4370c820401677ca251ad09ac64cc23c760764e75dElliott Hughes     * FileDescriptor with the corresponding SelectionKey.
4470c820401677ca251ad09ac64cc23c760764e75dElliott Hughes     */
4570c820401677ca251ad09ac64cc23c760764e75dElliott Hughes    public Object userData;
4670c820401677ca251ad09ac64cc23c760764e75dElliott Hughes
4770c820401677ca251ad09ac64cc23c760764e75dElliott Hughes    @Override public String toString() {
4870c820401677ca251ad09ac64cc23c760764e75dElliott Hughes        return "StructPollfd[fd=" + fd + ",events=" + events + ",revents=" + revents + "]";
4970c820401677ca251ad09ac64cc23c760764e75dElliott Hughes    }
5070c820401677ca251ad09ac64cc23c760764e75dElliott Hughes}
51