Greg Clayton | 3fb2c93 | 2013-02-16 22:46:58 +0000 | [diff] [blame] | 1 | //===--------------------- TimeSpecTimeout.cpp ------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "TimeSpecTimeout.h" |
| 11 | |
| 12 | using namespace lldb_private; |
| 13 | |
| 14 | const struct timespec * |
| 15 | TimeSpecTimeout::SetAbsoluteTimeoutMircoSeconds32 (uint32_t timeout_usec) |
| 16 | { |
| 17 | if (timeout_usec == UINT32_MAX) |
| 18 | { |
| 19 | m_infinite = true; |
| 20 | } |
| 21 | else |
| 22 | { |
| 23 | m_infinite = false; |
| 24 | TimeValue time_value(TimeValue::Now()); |
| 25 | time_value.OffsetWithMicroSeconds(timeout_usec); |
| 26 | m_timespec = time_value.GetAsTimeSpec(); |
| 27 | } |
| 28 | return GetTimeSpecPtr (); |
| 29 | } |
| 30 | |
| 31 | const struct timespec * |
| 32 | TimeSpecTimeout::SetRelativeTimeoutMircoSeconds32 (uint32_t timeout_usec) |
| 33 | { |
| 34 | if (timeout_usec == UINT32_MAX) |
| 35 | { |
| 36 | m_infinite = true; |
| 37 | } |
| 38 | else |
| 39 | { |
| 40 | m_infinite = false; |
| 41 | TimeValue time_value; |
| 42 | time_value.OffsetWithMicroSeconds(timeout_usec); |
| 43 | m_timespec = time_value.GetAsTimeSpec(); |
| 44 | } |
| 45 | return GetTimeSpecPtr (); |
| 46 | } |
| 47 | |
| 48 | |