~ubuntu-branches/ubuntu/wily/ruby-passenger/wily-proposed

« back to all changes in this revision

Viewing changes to ext/boost/thread/v2/thread.hpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2013-11-23 23:50:02 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20131123235002-8fdhsq7afj15o2z2
Tags: 4.0.25-1
* New upstream release.
* Refresh fix_install_path.patch.
* Build for Ruby 2.0 instead of 1.8. (Closes: #725591)
* Add fix_ftbfs_fortify_source.patch.
* Install passenger template files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
#include <boost/thread/detail/config.hpp>
10
10
#ifdef BOOST_THREAD_USES_CHRONO
11
11
#include <boost/chrono/system_clocks.hpp>
 
12
#include <boost/chrono/ceil.hpp>
12
13
#endif
13
14
#include <boost/thread/condition_variable.hpp>
14
 
#include <boost/thread/locks.hpp>
 
15
#include <boost/thread/lock_types.hpp>
15
16
 
16
17
namespace boost
17
18
{
20
21
 
21
22
#ifdef BOOST_THREAD_USES_CHRONO
22
23
 
23
 
    template <class Rep, class Period>
24
 
    void sleep_for(const chrono::duration<Rep, Period>& d)
25
 
    {
26
 
      using namespace chrono;
27
 
      nanoseconds ns = duration_cast<nanoseconds> (d);
28
 
      if (ns < d) ++ns;
29
 
      sleep_for(ns);
30
 
    }
31
 
 
32
24
    template <class Clock, class Duration>
33
25
    void sleep_until(const chrono::time_point<Clock, Duration>& t)
34
26
    {
40
32
        cv.wait_until(lk, t);
41
33
    }
42
34
 
 
35
#ifdef BOOST_THREAD_SLEEP_FOR_IS_STEADY
 
36
 
 
37
    template <class Rep, class Period>
 
38
    void sleep_for(const chrono::duration<Rep, Period>& d)
 
39
    {
 
40
      using namespace chrono;
 
41
      if (d > duration<Rep, Period>::zero())
 
42
      {
 
43
          duration<long double> Max = nanoseconds::max BOOST_PREVENT_MACRO_SUBSTITUTION ();
 
44
          nanoseconds ns;
 
45
          if (d < Max)
 
46
          {
 
47
              ns = duration_cast<nanoseconds>(d);
 
48
              if (ns < d)
 
49
                  ++ns;
 
50
          }
 
51
          else
 
52
              ns = nanoseconds:: max BOOST_PREVENT_MACRO_SUBSTITUTION ();
 
53
          sleep_for(ns);
 
54
      }
 
55
    }
 
56
 
43
57
    template <class Duration>
44
58
    inline BOOST_SYMBOL_VISIBLE
45
59
    void sleep_until(const chrono::time_point<chrono::steady_clock, Duration>& t)
47
61
      using namespace chrono;
48
62
      sleep_for(t - steady_clock::now());
49
63
    }
 
64
#else
 
65
    template <class Rep, class Period>
 
66
    void sleep_for(const chrono::duration<Rep, Period>& d)
 
67
    {
 
68
      using namespace chrono;
 
69
      if (d > duration<Rep, Period>::zero())
 
70
      {
 
71
        steady_clock::time_point c_timeout = steady_clock::now() + ceil<nanoseconds>(d);
 
72
        sleep_until(c_timeout);
 
73
      }
 
74
    }
 
75
 
 
76
#endif
50
77
 
51
78
#endif
52
79
  }