00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "ux.hpp"
00019
00020 using namespace Ux;
00021
00022
00023
00024
00025 int Aio::cancel(int fd)
00026 {
00027 #if _POSIX_ASYNCHRONOUS_IO > 0
00028 int r;
00029
00030 if ((r = ::aio_cancel(fd, this)) == -1)
00031 throw Error(errno);
00032 return r;
00033 #else
00034 throw Error(ENOSYS);
00035 #endif
00036 }
00037
00038
00039
00040
00041 int Aio::error(void)
00042 {
00043 #if _POSIX_ASYNCHRONOUS_IO > 0
00044 return ::aio_error(this);
00045 #else
00046 throw Error(ENOSYS);
00047 #endif
00048 }
00049
00050
00051
00052
00053 void Aio::sync(int op)
00054 {
00055 #if _POSIX_ASYNCHRONOUS_IO > 0
00056 if (::aio_fsync(op, this) == -1)
00057 throw Error(errno);
00058 #else
00059 throw Error(ENOSYS);
00060 #endif
00061 }
00062
00063
00064
00065
00066 void Aio::read(void)
00067 {
00068 #if _POSIX_ASYNCHRONOUS_IO > 0
00069 if (::aio_read(this) == -1)
00070 throw Error(errno);
00071 #else
00072 throw Error(ENOSYS);
00073 #endif
00074 }
00075
00076
00077
00078
00079 ssize_t Aio::return_status(void)
00080 {
00081 #if _POSIX_ASYNCHRONOUS_IO > 0
00082 ssize_t r;
00083
00084 if ((r = ::aio_return(this)) == -1)
00085 throw Error(errno);
00086 return r;
00087 #else
00088 throw Error(ENOSYS);
00089 #endif
00090 }
00091
00092
00093
00094
00095 void Aio::suspend(const struct aiocb *const list[], int cbcnt,
00096 const struct timespec *timeout)
00097 {
00098 #if _POSIX_ASYNCHRONOUS_IO > 0
00099 if (::aio_suspend(list, cbcnt, timeout) == -1)
00100 throw Error(errno);
00101 #else
00102 throw Error(ENOSYS);
00103 #endif
00104 }
00105
00106
00107
00108
00109 void Aio::write(void)
00110 {
00111 #if _POSIX_ASYNCHRONOUS_IO > 0
00112 if (::aio_write(this) == -1)
00113 throw Error(errno);
00114 #else
00115 throw Error(ENOSYS);
00116 #endif
00117 }
00118
00119
00120
00121
00122 void Aio::listio(int mode, struct aiocb *const list[],
00123 int cbcnt, struct sigevent *sig)
00124 {
00125 #if _POSIX_ASYNCHRONOUS_IO > 0
00126 if (::lio_listio(mode, list, cbcnt, sig) == -1)
00127 throw Error(errno);
00128 #else
00129 throw Error(ENOSYS);
00130 #endif
00131 }