proxygen
|
#include <AsyncIO.h>
Public Types | |
enum | State { State::UNINITIALIZED, State::INITIALIZED, State::PENDING, State::COMPLETED, State::CANCELED } |
typedef std::function< void(AsyncIOOp *)> | NotificationCallback |
Public Member Functions | |
AsyncIOOp (NotificationCallback cb=NotificationCallback()) | |
~AsyncIOOp () | |
void | pread (int fd, void *buf, size_t size, off_t start) |
void | pread (int fd, Range< unsigned char * > range, off_t start) |
void | preadv (int fd, const iovec *iov, int iovcnt, off_t start) |
void | pwrite (int fd, const void *buf, size_t size, off_t start) |
void | pwrite (int fd, Range< const unsigned char * > range, off_t start) |
void | pwritev (int fd, const iovec *iov, int iovcnt, off_t start) |
State | state () const |
void | reset (NotificationCallback cb=NotificationCallback()) |
void | setNotificationCallback (NotificationCallback cb) |
const NotificationCallback & | notificationCallback () const |
ssize_t | result () const |
Private Member Functions | |
void | init () |
void | start () |
void | complete (ssize_t result) |
void | cancel () |
Private Attributes | |
NotificationCallback | cb_ |
iocb | iocb_ |
State | state_ |
ssize_t | result_ |
Friends | |
class | AsyncIO |
std::ostream & | operator<< (std::ostream &stream, const AsyncIOOp &o) |
An AsyncIOOp represents a pending operation. You may set a notification callback or you may use this class's methods directly.
The op must remain allocated until it is completed or canceled.
typedef std::function<void(AsyncIOOp*)> folly::AsyncIOOp::NotificationCallback |
|
strong |
|
explicit |
folly::AsyncIOOp::~AsyncIOOp | ( | ) |
|
private |
Definition at line 67 of file AsyncIO.cpp.
References CANCELED, PENDING, and state_.
Referenced by folly::AsyncIO::doWait(), and notificationCallback().
|
private |
Definition at line 58 of file AsyncIO.cpp.
References cb_, COMPLETED, PENDING, result(), result_, and state_.
Referenced by folly::AsyncIO::doWait(), and notificationCallback().
|
private |
Definition at line 105 of file AsyncIO.cpp.
References INITIALIZED, state_, and UNINITIALIZED.
Referenced by notificationCallback(), pread(), preadv(), pwrite(), and pwritev().
|
inline |
void folly::AsyncIOOp::pread | ( | int | fd, |
void * | buf, | ||
size_t | size, | ||
off_t | start | ||
) |
void folly::AsyncIOOp::pread | ( | int | fd, |
Range< unsigned char * > | range, | ||
off_t | start | ||
) |
Definition at line 82 of file AsyncIO.cpp.
References folly::Range< Iter >::begin(), pread(), folly::Range< Iter >::size(), and start().
void folly::AsyncIOOp::preadv | ( | int | fd, |
const iovec * | iov, | ||
int | iovcnt, | ||
off_t | start | ||
) |
Definition at line 86 of file AsyncIO.cpp.
void folly::AsyncIOOp::pwrite | ( | int | fd, |
const void * | buf, | ||
size_t | size, | ||
off_t | start | ||
) |
void folly::AsyncIOOp::pwrite | ( | int | fd, |
Range< const unsigned char * > | range, | ||
off_t | start | ||
) |
Definition at line 96 of file AsyncIO.cpp.
References folly::Range< Iter >::begin(), pwrite(), folly::Range< Iter >::size(), and start().
void folly::AsyncIOOp::pwritev | ( | int | fd, |
const iovec * | iov, | ||
int | iovcnt, | ||
off_t | start | ||
) |
Definition at line 100 of file AsyncIO.cpp.
void folly::AsyncIOOp::reset | ( | NotificationCallback | cb = NotificationCallback() | ) |
Reset the operation for reuse. It is an error to call reset() on an Op that is still pending.
Definition at line 41 of file AsyncIO.cpp.
References cb_, iocb_, folly::gen::move, PENDING, result_, state_, and UNINITIALIZED.
Referenced by state().
ssize_t folly::AsyncIOOp::result | ( | ) | const |
Retrieve the result of this operation. Returns >=0 on success, -errno on failure (that is, using the Linux kernel error reporting conventions). Use checkKernelError (folly/Exception.h) on the result to throw a std::system_error in case of error instead.
It is an error to call this if the Op hasn't completed.
Definition at line 72 of file AsyncIO.cpp.
References COMPLETED, result_, and state_.
Referenced by complete(), and notificationCallback().
|
inline |
|
private |
Definition at line 53 of file AsyncIO.cpp.
References INITIALIZED, PENDING, and state_.
Referenced by notificationCallback(), pread(), pwrite(), and folly::AsyncIO::submit().
|
inline |
Return the current operation state.
Definition at line 80 of file AsyncIO.h.
References reset(), and state_.
Referenced by folly::AsyncIO::submit().
|
friend |
Definition at line 388 of file AsyncIO.cpp.
|
private |
Definition at line 113 of file AsyncIO.h.
Referenced by complete(), notificationCallback(), reset(), and setNotificationCallback().
|
private |
Definition at line 114 of file AsyncIO.h.
Referenced by AsyncIOOp(), folly::AsyncIO::doWait(), folly::operator<<(), pread(), preadv(), pwrite(), pwritev(), reset(), and folly::AsyncIO::submit().
|
private |
Definition at line 116 of file AsyncIO.h.
Referenced by complete(), folly::operator<<(), reset(), and result().
|
private |
Definition at line 115 of file AsyncIO.h.
Referenced by cancel(), complete(), init(), folly::operator<<(), reset(), result(), start(), state(), and ~AsyncIOOp().