示例#1
0
/*----------------------------------------------------------------------
|   NPT_System::Sleep
+---------------------------------------------------------------------*/
NPT_Result
NPT_System::Sleep(const NPT_TimeInterval& duration)
{
	DWORD timeout = (DWORD)duration.ToMillis();
	WaitForSingleObjectEx(NPT_WinRtSystem::Global.m_WaitEvent, timeout, FALSE);
    return NPT_SUCCESS;
}
示例#2
0
/*----------------------------------------------------------------------
|   NPT_System::Sleep
+---------------------------------------------------------------------*/
NPT_Result
NPT_System::Sleep(const NPT_TimeInterval& duration)
{
    ::Sleep((NPT_UInt32)duration.ToMillis());

    return NPT_SUCCESS;
}
示例#3
0
/*----------------------------------------------------------------------
|   NPT_System::Sleep
+---------------------------------------------------------------------*/
NPT_Result
NPT_System::Sleep(const NPT_TimeInterval& duration)
{
    struct timespec time_req;
    struct timespec time_rem;
    int             result;

    // setup the time value
    time_req.tv_sec  = (time_t)duration.ToNanos()/1000000000;
    time_req.tv_nsec = duration.ToNanos()%1000000000;

    // sleep
    do {
        result = nanosleep(&time_req, &time_rem);
        time_req = time_rem;
    } while (result == -1 && 
             errno == EINTR && 
             (long)time_req.tv_sec >= 0 && 
             (long)time_req.tv_nsec >= 0);

    return NPT_SUCCESS;
}
/*----------------------------------------------------------------------
|   PLT_DeviceData::SetLeaseTime
+---------------------------------------------------------------------*/
NPT_Result   
PLT_DeviceData::SetLeaseTime(NPT_TimeInterval lease_time, NPT_TimeStamp lease_time_last_update /* = 0 */) 
{
    // Enforce 10 seconds min lease time
    m_LeaseTime = (lease_time.ToSeconds()>=10)?lease_time:*PLT_Constants::GetInstance().GetDefaultDeviceLease();
    
    // get current time as last update time if none passed
    if ((double)lease_time_last_update == 0.) {
        NPT_System::GetCurrentTimeStamp(lease_time_last_update);
    }
    m_LeaseTimeLastUpdate = lease_time_last_update;
    return NPT_SUCCESS;
}
示例#5
0
/*----------------------------------------------------------------------
|    PLT_SsdpSearchTask::PLT_SsdpSearchTask
+---------------------------------------------------------------------*/
PLT_SsdpSearchTask::PLT_SsdpSearchTask(NPT_UdpSocket*                  socket,
                                       PLT_SsdpSearchResponseListener* listener, 
                                       NPT_HttpRequest*                request,
                                       NPT_TimeInterval                frequency) : 
    m_Listener(listener), 
    m_Request(request),
    m_Frequency(frequency?frequency:NPT_TimeInterval(30.)),
    m_Repeat(frequency.ToSeconds()!=0),
    m_Socket(socket)
{
    m_Socket->SetReadTimeout((NPT_Timeout)m_Frequency.ToMillis());
    m_Socket->SetWriteTimeout(10000);
}