当前位置: 首页>>代码示例>>C++>>正文


C++ queue::pop方法代码示例

本文整理汇总了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;
	}
}
开发者ID:petterreinholdtsen,项目名称:coz,代码行数:15,代码来源:producer_consumer.cpp

示例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);}
        }
    }
}
开发者ID:kitz99,项目名称:Problems,代码行数:15,代码来源:Source.cpp

示例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;
        }
开发者ID:LLNL,项目名称:Caliper,代码行数:15,代码来源:tree.hpp

示例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;
        }
    }
开发者ID:hvthaibk,项目名称:ccrunch,代码行数:16,代码来源:cThread.hpp

示例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;
}
开发者ID:Chiri23,项目名称:dolphin,代码行数:15,代码来源:SI_DeviceGBA.cpp

示例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);
	}
}
开发者ID:thesourcehim,项目名称:ppsspp,代码行数:16,代码来源:app-android.cpp

示例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;
}
开发者ID:dely123,项目名称:emu-ex-plus-alpha,代码行数:16,代码来源:cdromif.cpp

示例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);
}
开发者ID:pal1000,项目名称:ppsspp,代码行数:15,代码来源:app-android.cpp

示例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;
}
开发者ID:StephDiRaimondo,项目名称:xb_monitor,代码行数:48,代码来源:Hook.cpp

示例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);
                }
            }
        }
    }
开发者ID:LittleClown,项目名称:LittleClown.github.io,代码行数:16,代码来源:09.cpp

示例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;
		}
开发者ID:Nadasua,项目名称:HBNews,代码行数:16,代码来源:AIO.c

示例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();
    }
}
开发者ID:timur-losev,项目名称:framework2d,代码行数:16,代码来源:Test.cpp

示例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;
	}
开发者ID:NULUSIOS,项目名称:mame,代码行数:17,代码来源:xaudio2_sound.cpp

示例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);
    }
开发者ID:liuyq,项目名称:opencv,代码行数:16,代码来源:opengl_interop.cpp

示例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();
						}                              
					}
                }
开发者ID:Yashchuk,项目名称:diplom-1,代码行数:16,代码来源:threadPool.cpp


注:本文中的std::queue::pop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。