本文整理汇总了C++中std::queue::pop方法的典型用法代码示例。如果您正苦于以下问题:C++ queue::pop方法的具体用法?C++ queue::pop怎么用?C++ queue::pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::queue
的用法示例。
在下文中一共展示了queue::pop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: consumer
void* consumer(void* arg) {
while(true) {
pthread_mutex_lock(&queue_lock);
while(queue.size() == 0) {
pthread_cond_wait(&consumer_condvar, &queue_lock);
}
int front = queue.front();
queue.pop();
assert(front == 123);
consumed++;
pthread_mutex_unlock(&queue_lock);
pthread_cond_signal(&producer_condvar);
COZ_PROGRESS;
}
}
示例2: dijkstra
void dijkstra()
{
q.push(1);
d[1]=0;
while(!q.empty())
{
aux=q.front();q.pop();
for(unsigned int i = 0; i < a[aux].size(); ++i)
{
cost=a[aux][i].c; nod=a[aux][i].x;
if(d[nod]>d[aux]+cost)
{d[nod]=d[aux]+cost; q.push(nod);}
}
}
}
示例3: if
breadthfirst_iterator& operator++() {
if (node(m_t, m_n).child_head)
m_q.push(node(m_t, m_n).child_head);
if (node(m_t, m_n).next)
m_t = node(m_t, m_n).next;
else if (!m_q.empty()) {
m_t = m_q.front();
m_q.pop();
} else {
m_t = 0;
}
return *this;
}
示例4: wait_and_pop
bool wait_and_pop(T& data, std::chrono::microseconds waitingTime)
{
std::unique_lock<std::mutex> lockHandle(mutexHandle);
if (condFlag.wait_for(lockHandle, waitingTime,
[this]{return !queueHandle.empty();})) {
data = std::move(*queueHandle.front());
queueHandle.pop();
condFlag.notify_all();
return true;
}
else {
return false;
}
}
示例5: GetAvailableSock
bool GetAvailableSock(sf::SocketTCP& sock_to_fill)
{
bool sock_filled = false;
std::lock_guard<std::mutex> lk(cs_gba);
if (!waiting_socks.empty())
{
sock_to_fill = waiting_socks.front();
waiting_socks.pop();
sock_filled = true;
}
return sock_filled;
}
示例6: ProcessFrameCommands
// Call this under frameCommandLock.
static void ProcessFrameCommands(JNIEnv *env) {
while (!frameCommands.empty()) {
FrameCommand frameCmd;
frameCmd = frameCommands.front();
frameCommands.pop();
WLOG("frameCommand! '%s' '%s'", frameCmd.command.c_str(), frameCmd.params.c_str());
jstring cmd = env->NewStringUTF(frameCmd.command.c_str());
jstring param = env->NewStringUTF(frameCmd.params.c_str());
env->CallVoidMethod(nativeActivity, postCommand, cmd, param);
env->DeleteLocalRef(cmd);
env->DeleteLocalRef(param);
}
}
示例7: Read
// Returns FALSE if message not read, TRUE if it was read. Will always return TRUE if "blocking" is set.
bool CDIF_Queue::Read(CDIF_Message *message, bool blocking)
{
if(!blocking && ze_queue.size() == 0)
{
return FALSE;
}
MDFND_WaitSemaphore(ze_semaphore);
MDFND_LockMutex(ze_mutex);
assert(ze_queue.size() > 0);
*message = ze_queue.front();
ze_queue.pop();
MDFND_UnlockMutex(ze_mutex);
return TRUE;
}
示例8: UpdateRunLoopAndroid
void UpdateRunLoopAndroid(JNIEnv *env) {
NativeUpdate();
NativeRender(graphicsContext);
time_update();
std::lock_guard<std::mutex> guard(frameCommandLock);
if (!nativeActivity) {
while (!frameCommands.empty())
frameCommands.pop();
return;
}
// Still under lock here.
ProcessFrameCommands(env);
}
示例9: Hook_ReadFile
BOOL __stdcall Hook_ReadFile(HANDLE hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped)
{
if (hFile != hConnection) {
return __ReadFile(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped);
}
#if DEBUG_API
logmsg("ReadFile(%x, %p, %d, %p, %p)\n",
hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped);
#endif
if (replyBuffer.size())
{
if (nNumberOfBytesToRead >= replyBuffer.size())
nNumberOfBytesToRead = replyBuffer.size();
*lpNumberOfBytesRead = nNumberOfBytesToRead;
BYTE *ptr = (BYTE*) lpBuffer;
for (DWORD i=0; i < nNumberOfBytesToRead; i++) {
if (!replyBuffer.empty()) {
*ptr++ = replyBuffer.front();
replyBuffer.pop();
} else {
*lpNumberOfBytesRead = i;
break;
}
}
#if LOG_IO_STREAM
// logmsg("Lidos %d\n", nNumberOfBytesToRead);
ptr = (BYTE*) lpBuffer;
logmsg("SD: ");
for (DWORD i=0; i < nNumberOfBytesToRead; i++) {
logmsg_nt("%02X ", (DWORD) *ptr++);
}
logmsg_nt("\n");
#endif
} else {
*lpNumberOfBytesRead = 0;
return TRUE;
}
return TRUE;
}
示例10: BFS
void BFS() {
memset(dist, 0x3f, sizeof dist);
Q.push(t);
dist[t] = 0;
while( !Q.empty() ) {
int o = Q.front(); Q.pop();
for(int i=0; i < G[o].size(); ++i) {
edge& e = edges[G[o][i]];
if( dist[e.to] == INF && e.cap == 0 ) {
dist[e.to] = dist[o] + 1;
Q.push(e.to);
}
}
}
}
示例11: queue_pop
bool queue_pop(TaskItem& item)
{
pthread_mutex_lock(&m_mutex);
if(w_items.empty())
{
pthread_mutex_unlock(&m_mutex);
return false;
}
item.start_offset=w_items.front().start_offset;
item.size=w_items.front().size;
item.buffer=w_items.front().buffer;
item.sem=w_items.front().sem;
w_items.pop();
pthread_mutex_unlock(&m_mutex);
return true;
}
示例12: consume
static void consume()
{
while(true)
{
boost::mutex::scoped_lock lock(mutex);
if(messages.empty())
{
out << "Waiting..." << std::endl;
cond.wait(lock);
}
out << "Got " << messages.front() << std::endl;
messages.pop();
}
}
示例13: next
// get next buffer element from the pool
BYTE* next()
{
BYTE* next_buffer;
if (!m_queue.empty())
{
next_buffer = m_queue.front().release();
m_queue.pop();
}
else
{
next_buffer = new BYTE[m_buffersize];
memset(next_buffer, 0, m_buffersize);
}
return next_buffer;
}
示例14: getFps
static float getFps()
{
static std::queue<int64> time_queue;
int64 now = cv::getTickCount();
int64 then = 0;
time_queue.push(now);
if (time_queue.size() >= 2)
then = time_queue.front();
if (time_queue.size() >= 25)
time_queue.pop();
return time_queue.size() * (float)cv::getTickFrequency() / (now - then);
}
示例15: thread_fn
void thread_fn()
{
while (enabled)
{
std::unique_lock<std::mutex> locker(mutex);
cv.wait(locker, [&](){ return !fqueue.empty() || !enabled; });
while(!fqueue.empty())
{
fn_type fn = fqueue.front();
fqueue.pop();
locker.unlock();
fn();
locker.lock();
}
}
}