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


C++ sleep_milliseconds函数代码示例

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


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

示例1: l

void CPanasonic::UnloadNodes()
{
	int iRetryCounter = 0;

	boost::lock_guard<boost::mutex> l(m_mutex);

	m_ios.stop();	// stop the service if it is running
	sleep_milliseconds(100);

	while ((!m_pNodes.empty()) || (!m_ios.stopped()) && (iRetryCounter < 15))
	{
		std::vector<boost::shared_ptr<CPanasonicNode> >::iterator itt;
		for (itt = m_pNodes.begin(); itt != m_pNodes.end(); ++itt)
		{
			(*itt)->StopRequest();
			if (!(*itt)->IsBusy())
			{
				_log.Log(LOG_NORM, "Panasonic Plugin: (%s) Removing device.", (*itt)->m_Name.c_str());
				m_pNodes.erase(itt);
				break;
			}
		}
		iRetryCounter++;
		sleep_milliseconds(500);
	}
	m_pNodes.clear();
}
开发者ID:jonlar,项目名称:domoticz,代码行数:27,代码来源:PanasonicTV.cpp

示例2: StopHeartbeatThread

bool CLogitechMediaServer::StopHardware()
{
	StopHeartbeatThread();

	try {
		if (m_thread)
		{
			m_stoprequested = true;
			m_thread->join();
			m_thread.reset();

			//Make sure all our background workers are stopped
			int iRetryCounter = 0;
			while ((m_iThreadsRunning > 0) && (iRetryCounter<15))
			{
				sleep_milliseconds(500);
				iRetryCounter++;
			}
		}
	}
	catch (...)
	{
		//Don't throw from a Stop command
	}
	m_bIsStarted = false;
	return true;
}
开发者ID:saeedhadi,项目名称:domoticz,代码行数:27,代码来源:LogitechMediaServer.cpp

示例3: while

void CHardwareMonitor::Do_Work()
{
	_log.Log(LOG_STATUS, "Hardware Monitor: Started");

	int msec_counter = 0;
	int sec_counter = POLL_INTERVAL - 3;
	while (!m_stoprequested)
	{
		sleep_milliseconds(500);
		msec_counter++;
		if (msec_counter == 2)
		{
			msec_counter = 0;
			sec_counter++;
			if (sec_counter % 12 == 0) {
				m_LastHeartbeat = mytime(NULL);
			}

			if (sec_counter%POLL_INTERVAL == 0)
			{
				FetchData();
			}
		}
	}

	_log.Log(LOG_STATUS,"Hardware Monitor: Stopped...");			
}
开发者ID:gergles,项目名称:domoticz,代码行数:27,代码来源:HardwareMonitor.cpp

示例4: while

void C1Wire::SwitchThread()
{
	int pollPeriod = m_switchThreadPeriod;

	// Rescan the bus once every 10 seconds if requested
#define HARDWARE_RESCAN_PERIOD 10000
	int rescanIterations = HARDWARE_RESCAN_PERIOD / pollPeriod;
	if (0 == rescanIterations)
		rescanIterations = 1;

	int iteration = 0;

	m_bSwitchFirstTime = true;

	while (!m_stoprequested)
	{
		sleep_milliseconds(pollPeriod);

		if (0 == iteration++ % rescanIterations) // may glitch on overflow, not disastrous
		{
			if (m_bSwitchFirstTime)
			{
				m_bSwitchFirstTime = false;
				BuildSwitchList();
			}
		}

		PollSwitches();
	}

	_log.Log(LOG_STATUS, "1-Wire: Switch thread terminating");
}
开发者ID:dynasticorpheus,项目名称:domoticz,代码行数:32,代码来源:1Wire.cpp

示例5: l

void AsyncSerial::writeEnd(const boost::system::error_code& error)
{
    if(!error)
    {
        boost::lock_guard<boost::mutex> l(pimpl->writeQueueMutex);
        if(pimpl->writeQueue.empty())
        {
            pimpl->writeBuffer.reset();
            pimpl->writeBufferSize=0;
            sleep_milliseconds(75);
            return;
        }
        pimpl->writeBufferSize=pimpl->writeQueue.size();
        pimpl->writeBuffer.reset(new char[pimpl->writeQueue.size()]);
        copy(pimpl->writeQueue.begin(),pimpl->writeQueue.end(),
                pimpl->writeBuffer.get());
        pimpl->writeQueue.clear();
        async_write(pimpl->port,boost::asio::buffer(pimpl->writeBuffer.get(),
                pimpl->writeBufferSize),
                boost::bind(&AsyncSerial::writeEnd, this, boost::asio::placeholders::error));
    } else {
		try
		{
			setErrorStatus(true);
			doClose();
		}
		catch (...)
		{
			
		}
    }
}
开发者ID:AbsolutK,项目名称:domoticz,代码行数:32,代码来源:ASyncSerial.cpp

示例6: ReloadNodes

void CPanasonic::Do_Work()
{
	int scounter = 0;

	ReloadNodes();

	while (!m_stoprequested)
	{
		if (scounter++ >= (m_iPollInterval * 2))
		{
			boost::lock_guard<boost::mutex> l(m_mutex);

			scounter = 0;
			bool bWorkToDo = false;
			std::vector<boost::shared_ptr<CPanasonicNode> >::iterator itt;
			for (itt = m_pNodes.begin(); itt != m_pNodes.end(); ++itt)
			{
				if (!(*itt)->IsBusy())
				{
					_log.Log(LOG_NORM, "Panasonic Plugin: (%s) - Restarting thread.", (*itt)->m_Name.c_str());
					(*itt)->StartThread();
				}
				if ((*itt)->IsOn()) bWorkToDo = true;
			}
		}
		sleep_milliseconds(500);
	}
	UnloadNodes();
	_log.Log(LOG_STATUS, "Panasonic Plugin: Worker stopped...");
}
开发者ID:AbsolutK,项目名称:domoticz,代码行数:30,代码来源:PanasonicTV.cpp

示例7: while

void CPhilipsHue::Do_Work()
{
	int msec_counter = 0;
	int sec_counter = HUE_POLL_INTERVAL-2;

	_log.Log(LOG_STATUS,"Philips Hue: Worker started...");

	while (!m_stoprequested)
	{
		sleep_milliseconds(500);

		msec_counter++;
		if (msec_counter == 2)
		{
			msec_counter = 0;
			sec_counter++;
			if (sec_counter % HUE_POLL_INTERVAL == 0)
			{
				m_LastHeartbeat = mytime(NULL);
				GetStates();
			}
		}
	}
	_log.Log(LOG_STATUS,"Philips Hue: Worker stopped...");
}
开发者ID:interxis,项目名称:domoticz,代码行数:25,代码来源:PhilipsHue.cpp

示例8: while

void Comm5TCP::Do_Work()
{
	bool bFirstTime = true;
	int count = 0;
	while (!m_stoprequested)
	{
		m_LastHeartbeat = mytime(NULL);
		if (bFirstTime)
		{
			bFirstTime = false;
			if (!mIsConnected)
			{
				m_rxbufferpos = 0;
				connect(m_szIPAddress, m_usIPPort);
			}
		}
		else
		{
			sleep_milliseconds(40);
			update();
			if (count++ >= 100) {
				count = 0;
				querySensorState();
			}
		}
	}
	_log.Log(LOG_STATUS, "Comm5 MA-5XXX: TCP/IP Worker stopped...");
}
开发者ID:Digitaldna59,项目名称:domoticz,代码行数:28,代码来源:Comm5TCP.cpp

示例9: while

void MochadTCP::Do_Work()
{
	bool bFirstTime = true;

	while (!m_stoprequested)
	{

		time_t atime = mytime(NULL);
		struct tm ltime;
		localtime_r(&atime, &ltime);


		if (ltime.tm_sec % 12 == 0) {
			mytime(&m_LastHeartbeat);
		}
		if (bFirstTime)
		{
			bFirstTime = false;
			if (!mIsConnected)
			{
				m_rxbufferpos = 0;
				connect(m_szIPAddress, m_usIPPort);
			}
		}
		else
		{
			sleep_milliseconds(40);
			update();
		}
	}
	_log.Log(LOG_STATUS,"Mochad: TCP/IP Worker stopped...");
} 
开发者ID:AbsolutK,项目名称:domoticz,代码行数:32,代码来源:MochadTCP.cpp

示例10: UnloadNodes

void CPanasonic::ReloadNodes()
{
	UnloadNodes();

	//m_ios.reset();	// in case this is not the first time in

	std::vector<std::vector<std::string> > result;
	result = m_sql.safe_query("SELECT ID,Name,MacAddress,Timeout FROM WOLNodes WHERE (HardwareID==%d)", m_HwdID);
	if (result.size() > 0)
	{
		boost::lock_guard<boost::mutex> l(m_mutex);

		// create a vector to hold the nodes
		for (std::vector<std::vector<std::string> >::const_iterator itt = result.begin(); itt != result.end(); ++itt)
		{
			std::vector<std::string> sd = *itt;
			boost::shared_ptr<CPanasonicNode>	pNode = (boost::shared_ptr<CPanasonicNode>) new CPanasonicNode(m_HwdID, m_iPollInterval, m_iPingTimeoutms, sd[0], sd[1], sd[2], sd[3]);
			m_pNodes.push_back(pNode);
		}
		// start the threads to control each Panasonic TV
		for (std::vector<boost::shared_ptr<CPanasonicNode> >::iterator itt = m_pNodes.begin(); itt != m_pNodes.end(); ++itt)
		{
			_log.Log(LOG_NORM, "Panasonic Plugin: (%s) Starting thread.", (*itt)->m_Name.c_str());
			boost::thread* tAsync = new boost::thread(&CPanasonicNode::Do_Work, (*itt));
		}
		sleep_milliseconds(100);
		//_log.Log(LOG_NORM, "Panasonic Plugin: Starting I/O service thread.");
		//boost::thread bt(boost::bind(&boost::asio::io_service::run, &m_ios));
	}
}
开发者ID:jonlar,项目名称:domoticz,代码行数:30,代码来源:PanasonicTV.cpp

示例11: _configthreadlocale

void ZWaveBase::Do_Work()
{
#ifdef WIN32
	//prevent OpenZWave locale from taking over
	_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
#endif
	while (!m_stoprequested)
	{
		sleep_milliseconds(500);
		if (m_stoprequested)
			return;
		if (m_bInitState)
		{
			if (GetInitialDevices())
			{
				m_bInitState=false;
				sOnConnected(this);
			}
		}
		else
		{
			GetUpdates();
			if (m_bControllerCommandInProgress==true)
			{
				time_t atime=mytime(NULL);
				time_t tdiff=atime-m_ControllerCommandStartTime;
				if (tdiff>=CONTROLLER_COMMAND_TIMEOUT)
				{
					_log.Log(LOG_ERROR,"ZWave: Stopping Controller command (Timeout!)");
					CancelControllerCommand();
				}
			}
		}
	}
}
开发者ID:G3ronim0,项目名称:domoticz,代码行数:35,代码来源:ZWaveBase.cpp

示例12: while

void CPanasonicNode::Do_Work()
{
	m_Busy = true;
	if (DEBUG_LOGGING) _log.Log(LOG_NORM, "Panasonic Plugin: (%s) Entering work loop.", m_Name.c_str());
	int	iPollCount = 9;

	while (!m_stoprequested)
	{
		sleep_milliseconds(500);

		iPollCount++;
		if (iPollCount >= 10)
		{
			iPollCount = 0;
			try
			{
				std::string _volReply;
				std::string _muteReply;
				_volReply = handleWriteAndRead(buildXMLStringRendCtl("Get", "Volume"));
				if (_volReply != "ERROR")
				{
					int iVol = handleMessage(_volReply);
					m_CurrentStatus.Volume(iVol);
					if (m_CurrentStatus.Status() != MSTAT_ON && iVol > -1)
					{
						m_CurrentStatus.Status(MSTAT_ON);
						UpdateStatus();
					}
				}
				else
				{
					if (m_CurrentStatus.Status() != MSTAT_OFF)
					{
						m_CurrentStatus.Clear();
						m_CurrentStatus.Status(MSTAT_OFF);
						UpdateStatus();
					}
				}

				//_muteReply = handleWriteAndRead(buildXMLStringRendCtl("Get", "Mute"));
				//_log.Log(LOG_NORM, "Panasonic Plugin: (%s) Mute reply - \r\n", m_Name.c_str(), _muteReply.c_str());
				//if (_muteReply != "ERROR")
				//{
				//	m_CurrentStatus.Muted((handleMessage(_muteReply)==0) ? false : true);
				//}
				UpdateStatus();
			}
			catch (std::exception& e)
			{
				_log.Log(LOG_ERROR, "Panasonic Plugin: (%s) Exception: %s", m_Name.c_str(), e.what());
			}
		}
	}
	_log.Log(LOG_NORM, "Panasonic Plugin: (%s) Exiting work loop.", m_Name.c_str());
	m_Busy = false;
}
开发者ID:jonlar,项目名称:domoticz,代码行数:56,代码来源:PanasonicTV.cpp

示例13: sleep_milliseconds

void CDomoticzHardwareBase::StopHeartbeatThread()
{
	m_stopHeartbeatrequested = true;
	if (m_Heartbeatthread)
	{
		m_Heartbeatthread->join();
		// Wait a while. The read thread might be reading. Adding this prevents a pointer error in the async serial class.
		sleep_milliseconds(10);
	}
}
开发者ID:remb0,项目名称:domoticz,代码行数:10,代码来源:DomoticzHardware.cpp

示例14: x_check_status

/*
 * Called after most socket or tun/tap operations, via the inline
 * function check_status().
 *
 * Decide if we should print an error message, and see if we can
 * extract any useful info from the error, such as a Path MTU hint
 * from the OS.
 */
void
x_check_status (int status,
		const char *description,
		struct link_socket *sock,
		struct tuntap *tt)
{
  const int my_errno = (sock ? openvpn_errno_socket () : openvpn_errno ());
  const char *extended_msg = NULL;

  msg (x_cs_verbose_level, "%s %s returned %d",
       sock ? proto2ascii (sock->info.proto, true) : "",
       description,
       status);

  if (status < 0)
    {
      struct gc_arena gc = gc_new ();
#if EXTENDED_SOCKET_ERROR_CAPABILITY
      /* get extended socket error message and possible PMTU hint from OS */
      if (sock)
	{
	  int mtu;
	  extended_msg = format_extended_socket_error (sock->sd, &mtu, &gc);
	  if (mtu > 0 && sock->mtu != mtu)
	    {
	      sock->mtu = mtu;
	      sock->info.mtu_changed = true;
	    }
	}
#elif defined(WIN32)
      /* get possible driver error from TAP-Win32 driver */
      extended_msg = tap_win32_getinfo (tt, &gc);
#endif
      if (!ignore_sys_error (my_errno))
	{
	  if (extended_msg)
	    msg (x_cs_info_level, "%s %s [%s]: %s (code=%d)",
		 description,
		 sock ? proto2ascii (sock->info.proto, true) : "",
		 extended_msg,
		 strerror_ts (my_errno, &gc),
		 my_errno);
	  else
	    msg (x_cs_info_level, "%s %s: %s (code=%d)",
		 description,
		 sock ? proto2ascii (sock->info.proto, true) : "",
		 strerror_ts (my_errno, &gc),
		 my_errno);

	  if (x_cs_err_delay_ms)
	    sleep_milliseconds (x_cs_err_delay_ms);
	}
      gc_free (&gc);
    }
}
开发者ID:liuxfiu,项目名称:primogeni,代码行数:63,代码来源:error.c

示例15: write

bool KMTronicSerial::WriteInt(const unsigned char *data, const size_t len, const bool bWaitForReturn)
{
	if (!isOpen())
		return false;
	m_bHaveReceived = false;
	write((const char*)data, len);
	if (!bWaitForReturn)
		return true;
	sleep_milliseconds(100);
	return (m_bHaveReceived == true);
}
开发者ID:remb0,项目名称:domoticz,代码行数:11,代码来源:KMTronicSerial.cpp


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