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), sem(0)
61 #if STXXL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION
68 STXXL_ERRMSG(
"READ request submitted for a BID with a pending WRITE request");
77 #if STXXL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION
84 STXXL_ERRMSG(
"WRITE request submitted for a BID with a pending READ request");
102 bool was_still_in_queue =
false;
106 queue_type::iterator pos;
110 was_still_in_queue =
true;
117 queue_type::iterator pos;
121 was_still_in_queue =
true;
126 return was_still_in_queue;
136 self* pthis =
static_cast<self*
>(arg);
138 bool write_phase =
true;
146 if (!pthis->write_queue.empty())
149 pthis->write_queue.pop_front();
162 if (pthis->_priority_op ==
WRITE)
166 if (pthis->_priority_op ==
NONE
167 || pthis->_priority_op ==
READ)
174 if (!pthis->read_queue.empty())
177 pthis->read_queue.pop_front();
181 STXXL_VERBOSE2(
"queue: before serve request has " << req->nref() <<
" references ");
184 STXXL_VERBOSE2(
"queue: after serve request has " << req->nref() <<
" references ");
192 if (pthis->_priority_op ==
READ)
196 if (pthis->_priority_op ==
NONE
197 || pthis->_priority_op ==
WRITE)
203 if ((pthis->sem--) == 0)
212 #if STXXL_STD_THREADS && STXXL_MSVC >= 1700
void add_request(request_ptr &req)
state< thread_state > m_thread_state
void unlock()
unlock mutex hold prematurely
counting_ptr< request > request_ptr
A reference counting pointer for request.
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)
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.
static void * worker(void *arg)
#define STXXL_END_NAMESPACE