Date
2011-03-23.18:19:51
Message id
5667

Content

Proposed resolution:

  1. Change p2 in 20.11.3 [time.clock.req] as follows

    2 In Table 59 C1 and C2 denote clock types. t1 and t2 are values returned by C1::now() where the call returning t1 happens before (1.10) the call returning t2 and both of these calls happen occur before C1::time_point::max(). [ Note: This means C1 didn't wrap around between t1 and t2end note ]

  2. Add the following new requirement set at the end of sub-clause [time.clock.req]: [Comment: This requirement set is intentionally incomplete. The reason for this incompleteness is the based on the fact, that if we would make it right for C++0x, we would end up defining something like a complete ArithmeticLike concept for TC::rep, TC::duration, and TC::time_point. But this looks out-of scope for C++0x to me. The effect is that we essentially do not exactly say, which arithmetic or comparison operations can be used in the time-dependent functions from Clause 30, even though I expect that all declared functions of duration and time_point are well-formed and well-defined. — end comment]

    3 [ Note: the relative difference in durations between those reported by a given clock and the SI definition is a measure of the quality of implementation. — end note ]

    ? A type TC meets the TrivialClock requirements if:

    • TC satisfies the Clock requirements ([time.clock.req]),

    • the types TC::rep, TC::duration, and TC::time_point satisfy the requirements of EqualityComparable ([equalitycomparable]), LessThanComparable ([lessthancomparable]), DefaultConstructible ([defaultconstructible]), CopyConstructible ([copyconstructible]), CopyAssignable ([copyassignable]), Destructible ([destructible]), and of numeric types ([numeric.requirements]) [Note: This means in particular, that operations of these types will not throw exceptions — end note ],

    • lvalues of the types TC::rep, TC::duration, and TC::time_point are swappable ([swappable.requirements]),

    • the function TC::now() does not throw exceptions, and

    • the type TC::time_point::clock meets the TrivialClock requirements, recursively.

  3. Modify [time.clock] p. 1 as follows:

    1 - The types defined in this subclause shall satisfy the TrivialClock requirements (20.11.1).

  4. Modify [time.clock.system] p. 1, class system_clock synopsis, as follows:

    class system_clock {
    public:
      typedef see below rep;
      typedef ratio<unspecified , unspecified > period;
      typedef chrono::duration<rep, period> duration;
      typedef chrono::time_point<system_clock> time_point;
      static const bool is_monotonic is_steady = unspecified;
      static time_point now() noexcept;
      // Map to C API
      static time_t to_time_t (const time_point& t) noexcept;
      static time_point from_time_t(time_t t) noexcept;
    };
    
  5. Modify the prototype declarations in [time.clock.system] p. 3 + p. 4 as indicated (This edit also fixes the miss of the static specifier in these prototype declarations):

    static time_t to_time_t(const time_point& t) noexcept;
    
    static time_point from_time_t(time_t t) noexcept;
    
  6. Modify [time.clock.steady] p. 1, class steady_clock synopsis, as follows:

    class steady_clock {
    public:
      typedef unspecified rep;
      typedef ratio<unspecified , unspecified > period;
      typedef chrono::duration<rep, period> duration;
      typedef chrono::time_point<unspecified, duration> time_point;
      static const bool is_monotonic is_steady = true;
    
      static time_point now() noexcept;
    };
    
  7. Modify [time.clock.hires] p. 1, class high_resolution_clock synopsis, as follows:

    class high_resolution_clock {
    public:
      typedef unspecified rep;
      typedef ratio<unspecified , unspecified > period;
      typedef chrono::duration<rep, period> duration;
      typedef chrono::time_point<unspecified, duration> time_point;
      static const bool is_monotonic is_steady = unspecified;
    
      static time_point now() noexcept;
    };
    
  8. Add a new paragraph at the end of [thread.req.timing]:

    6 The resolution of timing provided by an implementation depends on both operating system and hardware. The finest resolution provided by an implementation is called the native resolution.

    ? Implementation-provided clocks that are used for these functions shall meet the TrivialClock requirements ([time.clock.req]).

  9. Edit the synopsis of [thread.thread.this] before p. 1. [Note: this duplicates edits also in D/N3267]:

    template <class Clock, class Duration>
    void sleep_until(const chrono::time_point<Clock, Duration>& abs_time) noexcept;
    template <class Rep, class Period>
    void sleep_for(const chrono::duration<Rep, Period>& rel_time) noexcept;
    
  10. Modify the prototype specifications in [thread.thread.this] before p. 4 and p. 6 and re-add a Throws element following the Synchronization elements at p. 5 and p. 7:

    template <class Clock, class Duration>
    void sleep_until(const chrono::time_point<Clock, Duration>& abs_time) noexcept;
    

    4 - [...]

    5 - Synchronization: None.

    ? - Throws: Nothing if Clock satisfies the TrivialClock requirements ([time.clock.req]) and operations of Duration do not throw exceptions. [Note: Instantiations of time point types and clocks supplied by the implementation as specified in [time.clock] do not throw exceptions. — end note]

    template <class Rep, class Period>
    void sleep_for(const chrono::duration<Rep, Period>& rel_time) noexcept;
    

    6 [...]

    7 Synchronization: None.

    ? Throws: Nothing if operations of chrono::duration<Rep, Period> do not throw exceptions. [Note: Instantiations of duration types supplied by the implementation as specified in [time.clock] do not throw exceptions. — end note]

  11. Fix a minor incorrectness in p. 5: Duration types need to compare against duration<>::zero(), not 0:

    3 The expression m.try_lock_for(rel_time) shall be well-formed and have the following semantics:

    [...]

    5 Effects: The function attempts to obtain ownership of the mutex within the relative timeout (30.2.4) specified by rel_time. If the time specified by rel_time is less than or equal to 0rel_time.zero(), the function attempts to obtain ownership without blocking (as if by calling try_lock()). The function shall return within the timeout specified by rel_time only if it has obtained ownership of the mutex object. [ Note: As with try_lock(), there is no guarantee that ownership will be obtained if the lock is available, but implementations are expected to make a strong effort to do so. — end note ]

  12. Modify the class timed_mutex synopsis in [thread.timedmutex.class] as indicated: [Note: this duplicates edits also in D/N3267]:

    class timed_mutex {
    public:
      [...]
      template <class Rep, class Period>
        bool try_lock_for(const chrono::duration<Rep, Period>& rel_time) noexcept;
      template <class Clock, class Duration>
        bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time) noexcept;
      [...]
    };
    
  13. Modify the class recursive_timed_mutex synopsis in [thread.timedmutex.recursive] as indicated: [Note: this duplicates edits also in D/N3267]:

    class recursive_timed_mutex {
    public:
      [...]
      template <class Rep, class Period>
        bool try_lock_for(const chrono::duration<Rep, Period>& rel_time) noexcept;
      template <class Clock, class Duration>
        bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time) noexcept;
      [...]
    };
    
  14. Modify the class template unique_lock synopsis in [thread.lock.unique] as indicated. [Note: this duplicates edits also in D/N3267]:

    template <class Mutex>
    class unique_lock {
    public:
      [...]
      template <class Clock, class Duration>
        unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time) noexcept;
      template <class Rep, class Period>
        unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time) noexcept;
      [...]
    };
    
  15. Modify the constructor prototypes in [thread.lock.unique.cons] before p. 14 and p. 17 [Note: this duplicates edits also in D/N3267]:

    template <class Clock, class Duration>
      unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time) noexcept;
    
    template <class Rep, class Period>
      unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time) noexcept;