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


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

本文整理汇总了C++中queue::get方法的典型用法代码示例。如果您正苦于以下问题:C++ queue::get方法的具体用法?C++ queue::get怎么用?C++ queue::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在queue的用法示例。


在下文中一共展示了queue::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sho_q

void sho_q(queue myque)
{
	cout << "Current queue: ";
	while(!myque.empty())
		cout << myque.get() << " ";
	cout << '\n';
	myque.put(9.9);
	myque.put(7.7);
	cout << "Now the copy is: ";
	while(!myque.empty())
		cout << myque.get() << " ";
	cout << '\n';
	return;
}
开发者ID:erangeljr,项目名称:datastructures,代码行数:14,代码来源:queueLinkedList.cpp

示例2: scheduler

void* scheduler(void *t)
{
	if(!DEBUG_MODE)
	{
		sleep(sleept);
	}
	struct requests r;
	int size=0;
	if (sched==FCFS)
	{
		while(1)
		{
			if(!q.empty())
			{
				q.get(r,size);
				pthread_mutex_lock(&exec_queue);
				tqueue.add(r,size);
				pthread_mutex_unlock(&exec_queue);
			}
		}
	}
	else
	{
		while(1)
		{
			if(!q.empty())
			{
				q.getshrt(r,size);
				pthread_mutex_lock(&exec_queue);
				tqueue.add(r,size);
				pthread_mutex_unlock(&exec_queue);
			}
		}
	}
	return NULL;
}
开发者ID:ssuryakumar89,项目名称:MultiThreaded_WebServer,代码行数:36,代码来源:myhttpd.cpp

示例3: execution_thread

void* execution_thread(void* d)
{
	struct requests r;
	int k;
	bool flag=false;
	std::string log;
	while(1)
	{
		pthread_mutex_lock(&exec_queue);
		if (!tqueue.empty())
		{

			tqueue.get(r,k);
			flag = true;
		}
		pthread_mutex_unlock(&exec_queue);
		if(flag)
		{
			log=r.log;
			//std::cout<<r.path<<std::endl;
			int ifsize=get_fsize(r.path);
			char fsize[4];
			sprintf(fsize,"%d",ifsize);
			char filept[100];
			strcpy(filept,r.path);
			if ( strncmp(r.http_ver, "HTTP/1.0", 8)!=0 && strncmp(r.http_ver, "HTTP/1.1", 8)!=0 )
			{
				write(r.sockfd, "HTTP/1.0 400 Bad Request\r\n", 26);
				write (r.sockfd, "\r\n",2);
				char *tstamp=get_timestamp();
				log.append("] [");
				log.append(tstamp);
				write(r.sockfd,tstamp,(((std::string)tstamp).length()-1));
				write (r.sockfd, "\r\n\r\n",4);
				shutdown (r.sockfd, SHUT_RDWR);
				close(r.sockfd);
				log.erase(log.length()-1);
				log.append("] \"");
				log.append(r.request_type);
				log.append(" ");
				log.append(r.path);
				log.append(" ");
				log.append(r.http_ver);
				log.erase(log.length()-1);
				log.append("\" 400 -1\n");
			}
			else
			{
				if(!r.is_dir)
				{
					if(!r.path_found)
					{
						write (r.sockfd, "HTTP/1.0 404 Not Found\r\n", 24);
						write(r.sockfd, "Date: ",6);
						char *tstamp=get_timestamp();
						log.append("] [");
						log.append(tstamp);
						write(r.sockfd,tstamp,(((std::string)tstamp).length()-1));
						write(r.sockfd,"\r\n",2);
						write(r.sockfd, "Server: ",8);
						write(r.sockfd, "Myhttpd/1.0\r\n",13);
						write(r.sockfd, "Content-Type: text/html\r\n",25);
						write (r.sockfd, "\r\n",2);
						shutdown (r.sockfd, SHUT_RDWR);
						close(r.sockfd);
						log.erase(log.length()-1);
						log.append("] \"");
						log.append(r.request_type);
						log.append(" ");
						log.append(r.path);
						log.append(" ");
						log.append(r.http_ver);
						log.erase(log.length()-1);
						log.append("\" 404 -1\n");
					}
					else
					{
						char *ftype=filetype(filept);
						if( strncmp(r.request_type,"GET\0",4)==0)
						{
							FILE *f;
							char *content=new char[ifsize];
							int bytes=0;
							write(r.sockfd, "HTTP/1.0 200 OK\r\n", 17);
							write(r.sockfd, "Date: ",6);
							char *tstamp=get_timestamp();
							log.append("] [");
							log.append(tstamp);
							write(r.sockfd,tstamp,(((std::string)tstamp).length()-1));
							write(r.sockfd,"\r\n",2);
							write(r.sockfd, "Server: ",8);
							write(r.sockfd, "Myhttpd/1.0\r\n",13);
							write(r.sockfd, "Last-Modified: ",15);
							write(r.sockfd,get_lastm(r.path),(((std::string)get_lastm(r.path)).length()-1));
							write(r.sockfd,"\r\n",2);
							write(r.sockfd,"Content-Type: ",14);
							if((ftype==NULL))
							{
								write(r.sockfd,"text/html\r\n",11);
							}
//.........这里部分代码省略.........
开发者ID:ssuryakumar89,项目名称:MultiThreaded_WebServer,代码行数:101,代码来源:myhttpd.cpp


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