bool isTerminated() { terminatelock.lock(); bool const isTerm = terminated; terminatelock.unlock(); return isTerm; }
void enque(value_type const q) { lock.lock(); Q.push_back(q); lock.unlock(); semaphore.post(); }
unsigned int getFillState() { lock.lock(); unsigned int const fill = Q.size(); lock.unlock(); return fill; }
bool peek(value_type & v) { lock.lock(); bool ok = Q.size() != 0; if ( ok ) v = Q.front(); lock.unlock(); return v; }
value_type deque() { semaphore.wait(); lock.lock(); value_type const v = Q.front(); Q.pop_front(); lock.unlock(); return v; }
value_type deque() { while ( !parent_type::semaphore.timedWait() ) { terminatelock.lock(); bool const isterminated = terminated; terminatelock.unlock(); if ( isterminated ) throw std::runtime_error("Queue is terminated"); } parent_type::lock.lock(); value_type const v = parent_type::Q.front(); parent_type::Q.pop_front(); parent_type::lock.unlock(); return v; }
value_type deque() { while ( !parent_type::semaphore.timedWait() ) { terminatelock.lock(); bool const isterminated = terminated >= terminatedthreshold; terminatelock.unlock(); if ( isterminated ) throw std::runtime_error("Heap is terminated"); } parent_type::lock.lock(); value_type const v = parent_type::Q.top(); parent_type::Q.pop(); parent_type::lock.unlock(); return v; }
/** * デフォルトコンストラクタ * @param createOnRun 作成と同時に実行開始するかのフラグ */ explicit PosixThread(bool createOnRun = false) throw (ThreadException) : threadId(), transporter(NULL), runningTarget(), isRun(false), starter(), statusSync() { starter.lock(); create(createOnRun); if (createOnRun == true) start(); }
value_type peek() { lock.lock(); if ( Q.size() ) { value_type const v = Q.front(); lock.unlock(); return v; } else { lock.unlock(); ::libmaus::exception::LibMausException se; se.getStream() << "SynchronousQueue::peek() called on empty queue." << std::endl; se.finish(); throw se; } }
value_type deque() { while ( !parent_type::semaphore.timedWait() ) { terminatelock.lock(); bool const isterminated = terminated; terminatelock.unlock(); if ( isterminated ) throw std::runtime_error("ReorderSet is terminated"); } parent_type::lock.lock(); typename parent_type::iterator_type const I = parent_type::Q.begin(); std::pair<uint64_t,value_type> const P = *I; value_type const v = P.second; parent_type::Q.erase(I); parent_type::lock.unlock(); return v; }
void terminate() { terminatelock.lock(); terminated = true; terminatelock.unlock(); }
void terminate() { terminatelock.lock(); terminated++; terminatelock.unlock(); }
/** * スレッドの実行 */ virtual void start() throw() { ScopedLock<PosixMutex> lock(statusSync); starter.unlock(); isRun = true; }