blob: 02714a749ef056d8899aa2e300c32c299e1d4428 [file] [log] [blame]
Vladimir Chtchetkine6dc5c2c2012-04-02 07:48:19 -07001/*
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. */
27typedef 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} AsyncIOState;
48
49/* Enumerates actions to perform with an I/O on state transition.
50 * Values from this enum are returned from async I/O callbacks, indicating what
51 * action should be performed with the I/O by I/O handler. */
52typedef enum AsyncIOAction {
53 /* I/O is done. Perform default action depending on I/O type. */
54 ASIO_ACTION_DONE,
55 /* Abort the I/O. */
56 ASIO_ACTION_ABORT,
57 /* Retry the I/O. */
58 ASIO_ACTION_RETRY,
59} AsyncIOAction;
60
61#endif /* ANDROID_ASYNC_IO_COMMON_H_ */