Home | History | Annotate | Download | only in android
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef ANDROID_ASYNC_IO_COMMON_H_
     18 #define ANDROID_ASYNC_IO_COMMON_H_
     19 
     20 /*
     21  * Contains declarations common for asynchronous socket I/O
     22  */
     23 
     24 /* Enumerates asynchronous I/O states.
     25  * Values from this enum are passed to callbacks associated with an I/O,
     26  * indicating at what state the I/O is. */
     27 typedef enum AsyncIOState {
     28     /* Asynchronous I/O has been queued.                (0) */
     29     ASIO_STATE_QUEUED,
     30     /* Asynchronous I/O has started. This state indicates that I/O has been
     31      * performed for the first time.                    (1) */
     32     ASIO_STATE_STARTED,
     33     /* Asynchronous I/O is continuing. This state indicates that I/O has been
     34      * invoked for the second (or more) time.           (2) */
     35     ASIO_STATE_CONTINUES,
     36     /* Asynchronous I/O is about to be retried.         (3) */
     37     ASIO_STATE_RETRYING,
     38     /* Asynchronous I/O has been successfuly completed. (4) */
     39     ASIO_STATE_SUCCEEDED,
     40     /* Asynchronous I/O has failed.                     (5) */
     41     ASIO_STATE_FAILED,
     42     /* Asynchronous I/O has timed out.                  (6) */
     43     ASIO_STATE_TIMED_OUT,
     44     /* Asynchronous I/O has been cancelled (due to disconnect, for
     45      * instance).                                       (7) */
     46     ASIO_STATE_CANCELLED,
     47     /* Asynchronous I/O is finished and is about to be discarder. This state is
     48      * useful in case there is an association between an I/O and some client's
     49      * component, that holds a reference associated with this I/O. When callback
     50      * is invoked with this state, it means that it's safe to drop that extra
     51      * reference associated with the I/O                (8) */
     52     ASIO_STATE_FINISHED,
     53 } AsyncIOState;
     54 
     55 /* Enumerates actions to perform with an I/O on state transition.
     56  * Values from this enum are returned from async I/O callbacks, indicating what
     57  * action should be performed with the I/O by I/O handler. */
     58 typedef enum AsyncIOAction {
     59     /* I/O is done. Perform default action depending on I/O type. */
     60     ASIO_ACTION_DONE,
     61     /* Abort the I/O. */
     62     ASIO_ACTION_ABORT,
     63     /* Retry the I/O. */
     64     ASIO_ACTION_RETRY,
     65 } AsyncIOAction;
     66 
     67 #endif  /* ANDROID_ASYNC_IO_COMMON_H_ */
     68