16 #if STXXL_HAVE_LINUXAIO_FILE
19 #include <sys/syscall.h>
29 #ifndef STXXL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION
30 #define STXXL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION 1
35 linuxaio_queue::linuxaio_queue(
int desired_queue_length)
36 : num_waiting_requests(0), num_free_events(0), num_posted_requests(0),
37 post_thread_state(NOT_RUNNING), wait_thread_state(NOT_RUNNING)
39 if (desired_queue_length == 0) {
63 STXXL_MSG(
"Set up an linuxaio queue with " << max_events <<
" entries.");
73 syscall(SYS_io_destroy,
context);
82 if (!dynamic_cast<linuxaio_request*>(req.
get()))
83 STXXL_ERRMSG(
"Non-LinuxAIO request submitted to LinuxAIO queue.");
97 if (!dynamic_cast<linuxaio_request*>(req.
get()))
98 STXXL_ERRMSG(
"Non-LinuxAIO request submitted to LinuxAIO queue.");
100 queue_type::iterator pos;
128 if (canceled_io_operation)
171 while (!dynamic_cast<linuxaio_request*>(req.
get())->post())
177 long num_events = syscall(SYS_io_getevents,
context, 1,
max_events, events, NULL);
178 if (num_events < 0) {
180 " io_getevents() nr_events=" << num_events);
208 for (
int e = 0; e < num_events; ++e)
238 if (num_events < 0) {
239 if (errno == EINTR) {
265 #if STXXL_STD_THREADS && STXXL_MSVC >= 1700
281 #if STXXL_STD_THREADS && STXXL_MSVC >= 1700
292 #endif // #if STXXL_HAVE_LINUXAIO_FILE
bool cancel_request(request_ptr &req)
static void * wait_async(void *arg)
void set_to(const value_type &new_state)
state< thread_state > post_thread_state
void unlock()
unlock mutex hold prematurely
Type * get() const
return the enclosed pointer.
bool empty() const
test for a NULL pointer
semaphore num_free_events
#define STXXL_THROW_INVALID_ARGUMENT(error_message)
Throws std::invalid_argument with "Error in [function] : [error_message]".
void stop_thread(thread_type &t, state< thread_state > &s, semaphore &sem)
void add_request(request_ptr &req)
int max_events
max number of OS requests
static void * post_async(void *arg)
semaphore num_posted_requests
void handle_events(io_event *events, long num_events, bool canceled)
aio_context_t context
OS context.
Aquire a lock that's valid until the end of scope.
#define STXXL_BEGIN_NAMESPACE
queue_type waiting_requests
queue_type posted_requests
state< thread_state > wait_thread_state
semaphore num_waiting_requests
number of requests in waitings_requests
choose_int_types< my_pointer_size >::unsigned_type unsigned_type
#define STXXL_THROW_ERRNO(exception_type, error_message)
Throws exception_type with "Error in [function] : [error_message] : [errno message]".
void start_thread(void *(*worker)(void *), void *arg, thread_type &t, state< thread_state > &s)
#define _STXXL_FORCE_SEQUENTIAL
Request for an linuxaio_file.
Queue for linuxaio_file(s)
ExtIterator find(ExtIterator begin, ExtIterator end, const EqualityComparable &value, int_type nbuffers=0)
External equivalent of std::find, see stxxl::find.
virtual void completed(bool canceled)=0
#define STXXL_END_NAMESPACE