• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ os_sleep函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中os_sleep函数的典型用法代码示例。如果您正苦于以下问题:C++ os_sleep函数的具体用法?C++ os_sleep怎么用?C++ os_sleep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: tunet_stop

VOID tunet_stop()
{
	logs_append(g_logs, "TUNET_STOP", NULL, NULL, 0);

	if(thread_tunet)
	{
		logout_socket_buffer = buffer_clear(logout_socket_buffer);

		tunet_state = TUNET_STATE_LOGOUT;
		while(tunet_state != TUNET_STATE_NONE && tunet_state != TUNET_STATE_ERROR)
			os_sleep(20);

		os_thread_kill(thread_tunet);
		while(thread_tunet)	os_sleep(20);

		main_socket_buffer = buffer_clear(main_socket_buffer);
		keepalive_socket_buffer = buffer_clear(keepalive_socket_buffer);
		logout_socket_buffer = buffer_clear(logout_socket_buffer);

		strcpy(keepalive_server, "");
		keepalive_server_port = 0;

		strcpy(msg_server, "");
		msg_server_port = 0;
	}

	logs_append(g_logs, "TUNET_STOP", "END", NULL, 0);
}
开发者ID:alick,项目名称:mytunet,代码行数:28,代码来源:tunet.c


示例2: fs2netd_reset_connection

void fs2netd_reset_connection()
{
	bool reset_gameserver = false;

	if (Net_player->flags & NETINFO_FLAG_MT_CONNECTED) {
		fs2netd_gameserver_disconnect();
		reset_gameserver = true;
	}

	FS2NetD_Disconnect();

	fs2netd_reset_state();

	// wait a little to allow for the port to clear
	os_sleep(500);

	// try to reinit the server connection
	fs2netd_login();

	os_sleep(250);

	if ( reset_gameserver && fs2netd_is_online() ) {
		fs2netd_gameserver_start();
	}
}
开发者ID:bryansee,项目名称:fs2open.github.com,代码行数:25,代码来源:fs2netd_client.cpp


示例3: main

int main( int argc, char **argv )
{
	void *pTaskHandle = NULL;
	
	enable_log( 1 );
	set_log( LOG_TYPE_CONSOLE, NULL, 0 );

	if( init_session(  ) < 0 )
		return -1;
		
	pTaskHandle = create_task( task_test, 5, 100 );
	if ( pTaskHandle )
	{
		CMessage stMsg;
		
		memset( &stMsg, 0x00, sizeof(stMsg) );
		
		post_task_msg( pTaskHandle, &stMsg );
		
		log_print( "create task ok................." );
	}
	else 
		log_print( "create task failed?????????????????????" );
	
	while ( 1 )
		os_sleep( 1000 );
		
	release_session(  );
	
	return 0;	
}
开发者ID:robertqingsong,项目名称:kpf,代码行数:31,代码来源:task_test.c


示例4: todo_wait_done

/*
 * blocking callers sleep here until the todo list is done
 */
static int todo_wait_done(void)
{
	di_debug("FUNC: %s\n", __func__);
	os_sleep(done_queue, todo.status == TODO_ST_DONE, 0);

	return todo.rc;
}
开发者ID:traveller42,项目名称:linux-2.6.28.mx233-falconwing,代码行数:10,代码来源:dryice.c


示例5: main

int main(void)
{
    Error	check_error = success;
    uint8	narrow;
    uint8	wide;

    os_sleep(100);

    CheckCleanup(os_boot(boot_module_table, LENGTH(boot_module_table)), boot_failure);
    CheckCleanup(record_command(0, null), record_failure);

  record_failure:	narrow = 2; wide = 1; goto failure;
  boot_failure:		narrow = 1; wide = os_boot_index(); goto failure;
  failure:
    while (!uart_character_ready())
	led_signal(narrow, wide);

    error_stack_print();

    write(PSTR("\r\n\r\nWavelogger v4.0\r\n"));
    write(PSTR("Reset reason: 0x%hx\r\n"), os_reset_reason());

    shell_run(shell_command_table, LENGTH(shell_command_table));

    return 0;
}
开发者ID:BackupGGCode,项目名称:wavelogger,代码行数:26,代码来源:main.c


示例6: wpa_supplicant_ctrl_iface_deinit

void wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv)
{
	struct wpa_ctrl_dst *dst, *prev;

	if (priv->sock > -1) {
		char *fname;
		char *buf, *dir = NULL, *gid_str = NULL;
		eloop_unregister_read_sock(priv->sock);
		if (priv->ctrl_dst) {
			/*
			 * Wait a second before closing the control socket if
			 * there are any attached monitors in order to allow
			 * them to receive any pending messages.
			 */
			wpa_printf(MSG_DEBUG, "CTRL_IFACE wait for attached "
				   "monitors to receive messages");
			os_sleep(1, 0);
		}
		close(priv->sock);
		priv->sock = -1;
		fname = wpa_supplicant_ctrl_iface_path(priv->wpa_s);
		if (fname) {
			unlink(fname);
			os_free(fname);
		}

		buf = os_strdup(priv->wpa_s->conf->ctrl_interface);
		if (buf == NULL)
			goto free_dst;
		if (os_strncmp(buf, "DIR=", 4) == 0) {
			dir = buf + 4;
			gid_str = os_strstr(dir, " GROUP=");
			if (gid_str) {
				*gid_str = '\0';
				gid_str += 7;
			}
		} else
			dir = buf;

		if (rmdir(dir) < 0) {
			if (errno == ENOTEMPTY) {
				wpa_printf(MSG_DEBUG, "Control interface "
					   "directory not empty - leaving it "
					   "behind");
			} else {
				perror("rmdir[ctrl_interface]");
			}
		}
		os_free(buf);
	}

free_dst:
	dst = priv->ctrl_dst;
	while (dst) {
		prev = dst;
		dst = dst->next;
		os_free(prev);
	}
	os_free(priv);
}
开发者ID:WiseMan787,项目名称:ralink_sdk,代码行数:60,代码来源:ctrl_iface_unix.c


示例7: wpa_supplicant_ctrl_iface_deinit

void wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv)
{
	struct wpa_ctrl_dst *dst, *prev;

	if (priv->sock > -1) {
		eloop_unregister_read_sock(priv->sock);
		if (priv->ctrl_dst) {
			/*
			 * Wait a second before closing the control socket if
			 * there are any attached monitors in order to allow
			 * them to receive any pending messages.
			 */
			wpa_printf(MSG_DEBUG, "CTRL_IFACE wait for attached "
				   "monitors to receive messages");
			os_sleep(1, 0);
		}
		close(priv->sock);
		priv->sock = -1;
	}

	dst = priv->ctrl_dst;
	while (dst) {
		prev = dst;
		dst = dst->next;
		os_free(prev);
	}
	os_free(priv);
}
开发者ID:MultiNet-80211,项目名称:Hostapd,代码行数:28,代码来源:ctrl_iface_udp.c


示例8: tunet_start

VOID tunet_start(USERCONFIG *uc)
{
	assert(uc != NULL);

	if(thread_tunet)
	{
		os_thread_kill(thread_tunet);
		while(thread_tunet) os_sleep(20);
	}


	logs_append(g_logs, "TUNET_START", NULL, NULL, 0);

	memcpy(&userconfig, uc, sizeof(USERCONFIG));
	
	strcpy(keepalive_server, "");
	keepalive_server_port = 0;

	strcpy(msg_server, "");
	msg_server_port = 0;

	main_socket = os_socket_tcp_close(main_socket);
	keepalive_socket = os_socket_tcp_close(keepalive_socket);
	logout_socket = os_socket_tcp_close(logout_socket);


	tunet_state = TUNET_STATE_LOGIN;

	main_socket_buffer = buffer_clear(main_socket_buffer);
	keepalive_socket_buffer = buffer_clear(keepalive_socket_buffer);
	logout_socket_buffer = buffer_clear(logout_socket_buffer);

	thread_tunet = os_thread_create(tunet_thread, NULL, FALSE, FALSE);
}
开发者ID:alick,项目名称:mytunet,代码行数:34,代码来源:tunet.c


示例9: run

void run(int nReaders, uint64_t bytes, bool sync) {
  ThreadPool q(nReaders * 2 + 8, sync);

  Server();
  for (int i = 0; i < nReaders; ++i)
    TcpReader(bytes);

  os_sleep(100 * 1000);
}
开发者ID:GorNishanov,项目名称:await,代码行数:9,代码来源:Awaitable.cpp


示例10: hostapd_channel_align_LTE_coex

u8 hostapd_channel_align_LTE_coex(struct hostapd_data *hapd, u8 oper_chan)
{
	int avail_ch_num, i;
	int avail_ch[14]={0};
	int fail_cnt = 0;
	struct wpa_driver_available_chan_s available_chan; 

	//No LTE COEX need for channels in 5GHz
	if (oper_chan > 14)
		return oper_chan;
	do {
	        os_memset(&available_chan, 0, sizeof(struct wpa_driver_available_chan_s));
                hostapd_drv_get_available_channel(hapd, (u8 *)&available_chan);
                    
		wpa_printf(MSG_DEBUG, "2G CHANNEL=0x%08x", available_chan.ch_2g_base1);
	        if (BIT(31) & available_chan.ch_2g_base1) {
	        	break;
	        } else {
			wpa_printf(MSG_DEBUG, "GET AVAILABLE CHANNEL: command failed");
	        	fail_cnt++;
			if(fail_cnt > 14)
	                	return oper_chan;
			os_sleep(0,1000*350);
		}
	} while(1);
	os_memset(avail_ch, 0, sizeof(avail_ch));
	avail_ch_num = 0;		
	for (i = 0; i < 14; i++) {
		if (BIT(i) & available_chan.ch_2g_base1) {
			avail_ch[avail_ch_num] = i + 1;
			avail_ch_num++;
		} else 
			continue;
	}

	wpa_printf(MSG_DEBUG,"DRIVER Report 2.4G available %d channel", avail_ch_num);
	for (i = 0; i < avail_ch_num; i++)
		wpa_printf(MSG_DEBUG,"Channel[%d] is fine", avail_ch[i]);
		
	wpa_printf(MSG_DEBUG,"Operating Channel = %d", oper_chan );		
	//align channel
	if (avail_ch_num > 0) {
		if (oper_chan <= avail_ch[0])
			oper_chan = avail_ch[0];
		else if (oper_chan >= avail_ch[avail_ch_num-1])
			oper_chan = avail_ch[avail_ch_num-1];
		else
				for (i = 0; i < avail_ch_num; i++) {
					if (oper_chan >= avail_ch[i])
						oper_chan = avail_ch[i];
				}	
		wpa_printf(MSG_DEBUG,"Align Operating Channel = %d", oper_chan );						
	}		

	return oper_chan;			
					
}
开发者ID:Bebooo43,项目名称:android_hardware_mediatek,代码行数:57,代码来源:ap_drv_ops.c


示例11: busy_run

void busy_run(long long loop, double sleep, struct busy_loop_data * busy_loop)
{
	while (loop > 0)
	{
		assert(busy_loop_run(busy_loop));
		os_sleep(sleep);
		loop--;
	}
}
开发者ID:srikanth007m,项目名称:sched_tests,代码行数:9,代码来源:main.c


示例12: led_flash

void led_flash(uint8 count, bool wide)
{
    led_set(0, false);
    led_set(1, false);

    for (uint8 i = 0; i < count; ++i)
    {
	if (wide) led_set(0, true);
	          led_set(1, true);

	os_sleep(25);

	led_set(0, false);
	led_set(1, false);

	os_sleep(25);
    }
}
开发者ID:BackupGGCode,项目名称:wavelogger,代码行数:18,代码来源:led_8.c


示例13: eloop_run

void eloop_run(void)
{
	int i;
	struct os_time tv, now;

	while (!eloop.terminate &&
		(eloop.timeout || eloop.reader_count > 0)) {
		if (eloop.timeout) {
			os_get_time(&now);
			if (os_time_before(&now, &eloop.timeout->time))
				os_time_sub(&eloop.timeout->time, &now, &tv);
			else
				tv.sec = tv.usec = 0;
		}

		/*
		 * TODO: wait for any event (read socket ready, timeout (tv),
		 * signal
		 */
		os_sleep(1, 0); /* just a dummy wait for testing */

		eloop_process_pending_signals();

		/* check if some registered timeouts have occurred */
		if (eloop.timeout) {
			struct eloop_timeout *tmp;

			os_get_time(&now);
			if (!os_time_before(&now, &eloop.timeout->time)) {
				tmp = eloop.timeout;
				eloop.timeout = eloop.timeout->next;
				tmp->handler(tmp->eloop_data,
					     tmp->user_data);
				free(tmp);
			}

		}

		eloop.reader_table_changed = 0;
		for (i = 0; i < eloop.reader_count; i++) {
			/*
			 * TODO: call each handler that has pending data to
			 * read
			 */
			if (0 /* TODO: eloop.readers[i].sock ready */) {
				eloop.readers[i].handler(
					eloop.readers[i].sock,
					eloop.readers[i].eloop_data,
					eloop.readers[i].user_data);
				if (eloop.reader_table_changed)
					break;
			}
		}
	}
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:55,代码来源:eloop_none.c


示例14: raw_socket_loop_thread

static THREADRET raw_socket_loop_thread(THREAD *self)
{
	CHAR buf[2*32767];
	
	ETHCARD_LOOP_RECV_PROC_PARAM *pp, p;
	size_t len = 0, recvlen = 0;
	struct sockaddr_ll addr;

	fd_set set;
	struct timeval tv;

	
	pp = (ETHCARD_LOOP_RECV_PROC_PARAM *)self->param;
	p.ethcard = pp->ethcard;
	p.proc = pp->proc;

	BYTE *pkt_data;

	os_thread_init_complete(self);	

	//pcap_loop(p.ethcard, 0, dispatcher_handler, (BYTE *)&p);
	while(os_thread_is_running(self) || os_thread_is_paused(self))
	{
		tv.tv_sec = 0;
		tv.tv_usec = 0;
		FD_ZERO(&set);
		FD_SET(p.ethcard->fd, &set);
		select(p.ethcard->fd + 1, &set, NULL, NULL, &tv);
		if( FD_ISSET(p.ethcard->fd, &set) )
		{
			len = sizeof(addr);  
			recvlen = recvfrom(p.ethcard->fd,(char *)buf, sizeof(buf), 0, (struct sockaddr *)&addr, &len);
	
			if(recvlen > 0)
			{
				pkt_data = (BYTE *)buf;
		
				if(addr.sll_protocol == 0x8e88)
					p.proc(p.ethcard, pkt_data, recvlen);
			}
			else
			{
				//must be something wrong....
			}			
		}
		else
		{
			//dprintf("ETH Sleep...\n");
			os_sleep(20);
		}
		os_thread_test_paused(self);
	}
	thread_ethcard_recv = os_thread_free(thread_ethcard_recv);	
	return 0;
}
开发者ID:alick,项目名称:mytunet,代码行数:55,代码来源:ethcard_eth.c


示例15: tunet_cleanup

VOID tunet_cleanup()
{
	os_thread_kill(thread_tunet);
	while(thread_tunet) os_sleep(20);

	main_socket_buffer = buffer_free(main_socket_buffer);
	keepalive_socket_buffer = buffer_free(keepalive_socket_buffer);
	logout_socket_buffer = buffer_free(logout_socket_buffer);

	keepalive_timeout = os_tick_free(keepalive_timeout);
}
开发者ID:alick,项目名称:mytunet,代码行数:11,代码来源:tunet.c


示例16: tunet_reset

VOID tunet_reset()
{
	logs_append(g_logs, "TUNET_RESET", NULL, NULL, 0);
	if(thread_tunet)
	{
		os_thread_kill(thread_tunet);
		while(thread_tunet) os_sleep(20);
	}

	tunet_state = TUNET_STATE_NONE;
}
开发者ID:alick,项目名称:mytunet,代码行数:11,代码来源:tunet.c


示例17: fsl_shw_get_random

/*!
 * Get random data.
 *
 * @param      user_ctx  A user context from #fsl_shw_register_user().
 * @param      length    The number of octets of @a data being requested.
 * @param data      A pointer to a location of @a length octets to where
 *                       random data will be returned.
 *
 * @return     FSL_RETURN_NO_RESOURCE_S  A return code of type #fsl_shw_return_t.
 *             FSL_RETURN_OK_S
 */
fsl_shw_return_t fsl_shw_get_random(fsl_shw_uco_t * user_ctx, uint32_t length,
				    uint8_t * data)
{
	fsl_shw_return_t return_code = FSL_RETURN_NO_RESOURCE_S;
	/* Boost up length to cover any 'missing' bytes at end of a word */
	uint32_t *buf = os_alloc_memory(length + 3, 0);
	volatile rng_work_entry_t *work = os_alloc_memory(sizeof(*work), 0);

	if ((rng_availability != RNG_STATUS_OK) || (buf == NULL)
	    || (work == NULL)) {
		if (rng_availability != RNG_STATUS_OK) {
			LOG_KDIAG_ARGS("rng not available: %d\n",
				       rng_availability);
		} else {
			LOG_KDIAG_ARGS
			    ("Resource allocation failure: %d or %d bytes",
			     length, sizeof(*work));
		}
		/* Cannot perform function.  Clean up and clear out. */
		if (buf != NULL) {
			os_free_memory(buf);
		}
		if (work != NULL) {
			os_free_memory((void *)work);
		}
	} else {
		unsigned blocking = user_ctx->flags & FSL_UCO_BLOCKING_MODE;

		work->hdr.user_ctx = user_ctx;
		work->hdr.flags = user_ctx->flags;
		work->hdr.callback = user_ctx->callback;
		work->hdr.user_ref = user_ctx->user_ref;
		work->hdr.postprocess = finish_random;
		work->length = length;
		work->data_local = buf;
		work->data_user = data;

		RNG_ADD_WORK_ENTRY((rng_work_entry_t *) work);

		if (blocking) {
			os_sleep(rng_wait_queue, work->completed != FALSE,
				 FALSE);
			finish_random((shw_queue_entry_t *) work);
			return_code = work->hdr.code;
			os_free_memory((void *)work);
		} else {
			return_code = FSL_RETURN_OK_S;
		}
	}

	return return_code;
}				/* fsl_shw_get_entropy */
开发者ID:despierto,项目名称:imx_233_linux,代码行数:63,代码来源:rng_driver.c


示例18: wpatalk_reconnect

/* wpatalk_reconnect -- maybe reconnect.
 * If previously connected, disconnects and aborts unless "keep_going"
 * is set (-k option).
 */
static void wpatalk_reconnect(void)
{
    if (ctrl_conn) {
        wpatalk_close_connection();
        if (!keep_going) {
            wpatalk_fatal("Exiting due to lost connection");
        }
    }
    for (;;) {
        if (wpatalk_get_socket_path() == 0) {
            #ifdef CONFIG_CTRL_IFACE_UNIX
            ctrl_conn = wpa_ctrl_open(socket_path);
            #else
            #error "wpatalk_open_connection configuration error"
            #endif
        }
        if (ctrl_conn) {
            if (wpa_ctrl_attach(ctrl_conn) == 0) {
                if (warning_displayed || verbose) {
                    wpatalk_info(
                        "Connection (re)established to daemon=%s interface=%s",
                        daemon_name, ctrl_ifname);
                    wpatalk_info("... using socket-file=%s", socket_path);
                    warning_displayed = 0;
 	        }
                wpatalk_attached = 1;
                return;
            } else {
                if (!warning_displayed) {
                    wpatalk_warning(
                        "Failed to attach to daemon %s", daemon_name);
                }
                wpatalk_close_connection();
                ctrl_conn = NULL;
            }
        }
        if (!keep_going) {
            wpatalk_fatal("Failed to connect to daemon %s errno %d "
                        "using socket file %s", 
                daemon_name, errno, socket_path);
            return;
        }
        if (!warning_displayed) {
            wpatalk_info("Could not connect to daemon %s -- re-trying",
                    daemon_name);
            warning_displayed = 1;
        }
        os_sleep(1, 0);
    }

    return;
}
开发者ID:KHATEEBNSIT,项目名称:AP,代码行数:56,代码来源:wpatalk.c


示例19: main_child

void main_child(int pid, void * data)
{
	struct busy_data * busy =
		(struct busy_data *)data;

	os_sleep(1); /* allows the other fork to happen ASAP */
	os_nice_set(pid, busy->nice);

	busy_run((int)(busy->total_sequential_time / (busy->running_time + busy->sleeping_time)),
			busy->sleeping_time,
			busy->busy_loop);
	main_cleanup(busy);
}
开发者ID:srikanth007m,项目名称:sched_tests,代码行数:13,代码来源:main.c


示例20: led_init

Error led_init()
{
    DDRC = 0x60;

    for (uint i = 0; i < 20; ++i)
    {
	led_set(i & 1, true);
	led_set((i + 1) & 1, false);
	os_sleep(10);
    }

    return success;
}
开发者ID:BackupGGCode,项目名称:wavelogger,代码行数:13,代码来源:led_8.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ os_snprintf函数代码示例发布时间:2022-05-30
下一篇:
C++ os_realloc_array函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap