]>
Commit | Line | Data |
---|---|---|
97eba8fc BP |
1 | /* Copyright (c) 2013 Nicira, Inc. |
2 | * | |
3 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | * you may not use this file except in compliance with the License. | |
5 | * You may obtain a copy of the License at: | |
6 | * | |
7 | * http://www.apache.org/licenses/LICENSE-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, software | |
10 | * distributed under the License is distributed on an "AS IS" BASIS, | |
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | * See the License for the specific language governing permissions and | |
13 | * limitations under the License. | |
14 | */ | |
15 | ||
16 | #ifndef ASYNC_APPEND_H | |
17 | #define ASYNC_APPEND_H 1 | |
18 | ||
19 | #include <stddef.h> | |
20 | ||
21 | /* This module defines a simple, abstract interface to asynchronous file I/O. | |
22 | * It is currently used only for logging. Thus, for now the interface only | |
23 | * supports appending to a file. Multiple implementations are possible | |
24 | * depending on the operating system's degree and form of support for | |
25 | * asynchronous I/O. | |
26 | * | |
27 | * The comments below document the requirements on any implementation. | |
28 | * | |
29 | * Thread-safety | |
30 | * ============= | |
31 | * | |
32 | * Only a single thread may use a given 'struct async_append' at one time. | |
33 | */ | |
34 | ||
97eba8fc | 35 | /* Creates and returns a new asynchronous appender for file descriptor 'fd', |
888e0cf4 BP |
36 | * which the caller must have opened in append mode (O_APPEND). If the system |
37 | * is for some reason unable to support asynchronous I/O on 'fd' this function | |
38 | * may return NULL. */ | |
97eba8fc BP |
39 | struct async_append *async_append_create(int fd); |
40 | ||
41 | /* Destroys 'ap', without closing its underlying file descriptor. */ | |
42 | void async_append_destroy(struct async_append *ap); | |
43 | ||
44 | /* Appends the 'size' bytes of 'data' to 'ap', asynchronously if possible. */ | |
45 | void async_append_write(struct async_append *ap, | |
46 | const void *data, size_t size); | |
47 | ||
48 | /* Blocks until all data asynchronously written to 'ap' with | |
49 | * async_append_write() has been committed to the point that it will be written | |
50 | * to disk barring an operating system or hardware failure. */ | |
51 | void async_append_flush(struct async_append *ap); | |
52 | ||
53 | #endif /* async-append.h */ |