~ubuntu-branches/ubuntu/saucy/filezilla/saucy-proposed

« back to all changes in this revision

Viewing changes to src/engine/rtt.cpp

  • Committer: Package Import Robot
  • Author(s): Adrien Cunin
  • Date: 2012-12-07 17:17:17 UTC
  • mfrom: (1.1.31)
  • Revision ID: package-import@ubuntu.com-20121207171717-nt6as62u4pa1uv11
Tags: 3.6.0.2-1ubuntu1
* Merge from Debian experimental. Remaining Ubuntu change:
   - Added debian/patches/11_use-decimal-si-by-default.patch in order to
     comply with UnitsPolicy

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <filezilla.h>
 
2
#include "rtt.h"
 
3
 
 
4
CLatencyMeasurement::CLatencyMeasurement()
 
5
        : m_measurements()
 
6
{
 
7
}
 
8
 
 
9
int CLatencyMeasurement::GetLatency() const
 
10
{
 
11
        wxCriticalSectionLocker lock(m_sync);
 
12
        if (!m_measurements)
 
13
                return -1;
 
14
 
 
15
        return static_cast<int>(m_summed_latency.GetValue() / m_measurements);
 
16
}
 
17
 
 
18
bool CLatencyMeasurement::Start()
 
19
{
 
20
        wxCriticalSectionLocker lock(m_sync);
 
21
        if (m_start.IsValid())
 
22
                return false;
 
23
 
 
24
        m_start = wxDateTime::UNow();
 
25
 
 
26
        return true;
 
27
}
 
28
 
 
29
bool CLatencyMeasurement::Stop()
 
30
{
 
31
        wxCriticalSectionLocker lock(m_sync);
 
32
        if (!m_start.IsValid())
 
33
                return false;
 
34
 
 
35
        wxTimeSpan diff = wxDateTime::UNow() - m_start;
 
36
        m_start = wxDateTime();
 
37
 
 
38
        if (diff.GetMilliseconds() < 0)
 
39
                return false;
 
40
 
 
41
        m_summed_latency += diff.GetMilliseconds();
 
42
        ++m_measurements;
 
43
        
 
44
        return true;
 
45
}
 
46
 
 
47
void CLatencyMeasurement::Reset()
 
48
{
 
49
        wxCriticalSectionLocker lock(m_sync);
 
50
        m_summed_latency = 0;
 
51
        m_measurements = 0;
 
52
        m_start = wxDateTime();
 
53
}
 
54
 
 
55
void CLatencyMeasurement::cb()
 
56
{
 
57
        Stop();
 
58
}
 
 
b'\\ No newline at end of file'