22 #include <foxxll/config.hpp> 26 #if FOXXLL_MSVC >= 1700 && FOXXLL_MSVC <= 1800 30 #ifndef FOXXLL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION 31 #define FOXXLL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION 1 36 struct file_offset_match
37 :
public std::binary_function<request_ptr, request_ptr, bool>
44 return (a->offset() == b->offset()) &&
45 (a->get_file() == b->get_file());
50 : thread_state_(NOT_RUNNING), sem_(0)
68 if (!dynamic_cast<serving_request*>(req.
get()))
69 TLX_LOG1 <<
"Incompatible request submitted to running queue.";
71 #if FOXXLL_CHECK_FOR_PENDING_REQUESTS_ON_SUBMISSION 76 bind2nd(file_offset_match(), req)
80 TLX_LOG1 <<
"request submitted for a BID with a pending request";
96 if (!dynamic_cast<serving_request*>(req.
get()))
97 TLX_LOG1 <<
"Incompatible request submitted to running queue.";
99 bool was_still_in_queue =
false;
102 queue_type::iterator pos
108 was_still_in_queue =
true;
114 return was_still_in_queue;
124 self* pthis =
static_cast<self*
>(arg);
131 std::unique_lock<std::mutex> lock(pthis->queue_mutex_);
132 if (!pthis->queue_.empty())
135 pthis->queue_.pop_front();
146 pthis->sem_.signal();
152 if (pthis->sem_.wait() == 0)
155 pthis->sem_.signal();
161 #if FOXXLL_MSVC >= 1700 && FOXXLL_MSVC <= 1800
#define FOXXLL_THROW_INVALID_ARGUMENT(error_message)
Throws std::invalid_argument with "Error in [function] : [error_message]".
shared_state< thread_state > thread_state_
tlx::counting_ptr< request > request_ptr
A reference counting pointer for request.
void add_request(request_ptr &req) final
Type * get() const noexcept
return the enclosed pointer.
void set_priority_op(const priority_op &op) final
bool cancel_request(request_ptr &req) final
static void * worker(void *arg)
size_t wait(size_t delta=1, size_t slack=0)
void stop_thread(std::thread &t, shared_state< thread_state > &s, tlx::semaphore &sem)
High-performance smart pointer used as a wrapping reference counting pointer.
Request which serves an I/O by calling the synchronous routine of the file.
bool empty() const noexcept
test for a nullptr pointer
request_queue_impl_1q(int n=1)
void start_thread(void *(*worker)(void *), void *arg, std::thread &t, shared_state< thread_state > &s)