23 #if STXXL_STD_THREADS && STXXL_MSVC >= 1700
27 #ifndef STXXL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION
28 #define STXXL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION 1
33 struct file_offset_match :
public std::binary_function<request_ptr, request_ptr, bool>
40 return (a->get_offset() == b->get_offset()) &&
41 (a->get_file() == b->get_file());
45 request_queue_impl_qwqr::request_queue_impl_qwqr(
int n)
46 : m_thread_state(NOT_RUNNING), m_sem(0)
58 if (!dynamic_cast<serving_request*>(req.
get()))
59 STXXL_ERRMSG(
"Incompatible request submitted to running queue.");
63 #if STXXL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION
70 STXXL_ERRMSG(
"READ request submitted for a BID with a pending WRITE request");
79 #if STXXL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION
86 STXXL_ERRMSG(
"WRITE request submitted for a BID with a pending READ request");
103 if (!dynamic_cast<serving_request*>(req.
get()))
104 STXXL_ERRMSG(
"Incompatible request submitted to running queue.");
106 bool was_still_in_queue =
false;
110 queue_type::iterator pos
116 was_still_in_queue =
true;
123 queue_type::iterator pos
129 was_still_in_queue =
true;
134 return was_still_in_queue;
144 self* pthis =
static_cast<self*
>(arg);
146 bool write_phase =
true;
154 if (!pthis->m_write_queue.empty())
157 pthis->m_write_queue.pop_front();
170 if (pthis->m_priority_op ==
WRITE)
174 if (pthis->m_priority_op ==
NONE || pthis->m_priority_op ==
READ)
181 if (!pthis->m_read_queue.empty())
184 pthis->m_read_queue.pop_front();
199 if (pthis->m_priority_op ==
READ)
203 if (pthis->m_priority_op ==
NONE || pthis->m_priority_op ==
WRITE)
209 if ((pthis->m_sem--) == 0)
218 #if STXXL_STD_THREADS && STXXL_MSVC >= 1700
Implementation of a local request queue having two queues, one for read and one for write requests...
void add_request(request_ptr &req)
state< thread_state > m_thread_state
void unlock()
unlock mutex hold prematurely
Type * get() const
return the enclosed pointer.
bool empty() const
test for a NULL pointer
#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)
#define STXXL_VERBOSE2(x)
Request which serves an I/O by calling the synchronous routine of the file.
counting_ptr< request > request_ptr
A reference counting pointer for request.
Aquire a lock that's valid until the end of scope.
#define STXXL_BEGIN_NAMESPACE
void STXXL_UNUSED(const U &)
bool cancel_request(request_ptr &req)
request_type get_type() const
~request_queue_impl_qwqr()
void start_thread(void *(*worker)(void *), void *arg, thread_type &t, state< thread_state > &s)
#define _STXXL_FORCE_SEQUENTIAL
ExtIterator find(ExtIterator begin, ExtIterator end, const EqualityComparable &value, int_type nbuffers=0)
External equivalent of std::find, see stxxl::find.
unsigned_type get_reference_count() const
Return the number of references to this object (for debugging)
static void * worker(void *arg)
#define STXXL_END_NAMESPACE