Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated common:Time #90

Merged
merged 17 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/ci-bionic/after_make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ mkdir build
cd build
cmake ..
make

# return to the compilation place
cd ../../build
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ message(STATUS "\n\n-- ====== Finding Dependencies ======")

#--------------------------------------
# Find ignition-math
ign_find_package(ignition-math6 REQUIRED_BY graphics events)
ign_find_package(ignition-math6 REQUIRED_BY graphics events VERSION 6.6)
set(IGN_MATH_VER ${ignition-math6_VERSION_MAJOR})

#--------------------------------------
Expand Down
14 changes: 7 additions & 7 deletions include/ignition/common/Time.hh
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,31 @@ namespace ignition
};

/// \brief Constructors
public: Time();
public: IGN_DEPRECATED(4) Time();

/// \brief Copy constructor
/// \param[in] time Time to copy
public: Time(const Time &_time);
public: IGN_DEPRECATED(4) Time(const Time &_time);

/// \brief Constructor
/// \param[in] _tv Time to initialize to
public: explicit Time(const struct timespec &_tv);
public: explicit IGN_DEPRECATED(4) Time(const struct timespec &_tv);

/// \brief Constructor
/// \param[in] _sec Seconds
/// \param[in] _nsec Nanoseconds
public: Time(int32_t _sec, int32_t _nsec);
public: IGN_DEPRECATED(4) Time(int32_t _sec, int32_t _nsec);

/// \brief Constuctor
/// \param[in] _time Time in double format sec.nsec
public: explicit Time(double _time);
public: explicit IGN_DEPRECATED(4) Time(double _time);

/// \brief Destructor
public: virtual ~Time();

/// \brief Get the wall time
/// \return the current time
public: static const Time &SystemTime();
public: static const IGN_DEPRECATED(4) Time &SystemTime();

/// \brief Set to sec and nsec
/// \param[in] _sec Seconds
Expand All @@ -103,7 +103,7 @@ namespace ignition
/// actual call to the system's sleep function.
///
/// On Windows the return value is always common::Time::Zero.
public: static Time Sleep(const common::Time &_time);
public: static Time IGN_DEPRECATED(4) Sleep(const common::Time &_time);

/// \brief Get the time as a string formatted as "DD hh:mm:ss.mmm", with
/// the option to choose the start/end.
Expand Down
14 changes: 10 additions & 4 deletions include/ignition/common/Timer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,27 @@ namespace ignition

/// \brief Get the elapsed time
/// \return The time
public: Time Elapsed() const;
public: Time IGN_DEPRECATED(4) Elapsed() const;

/// \brief Get the elapsed time
/// \return The elapsed time
public: std::chrono::duration<double> ElapsedTime() const;

/// \brief Stream operator friendly
public: friend std::ostream &operator<<(std::ostream &out,
const ignition::common::Timer &t)
{
out << t.Elapsed();
out << t.ElapsedTime().count();
return out;
}

IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \brief The time of the last call to Start
private: Time start;
private: std::chrono::steady_clock::time_point start;

/// \brief The time when Stop was called.
private: Time stop;
private: std::chrono::steady_clock::time_point stop;
IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING

/// \brief True if the timer is running.
private: bool running;
Expand Down
11 changes: 10 additions & 1 deletion include/ignition/common/WorkerPool.hh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ namespace ignition
/// \returns true if all work was finished
/// \remarks The return value can be false even when waiting forever if
// the WorkerPool is destructed before all work is completed
public: bool WaitForResults(const Time &_timeout = Time::Zero);
public: bool IGN_DEPRECATED(4) WaitForResults(const Time &_timeout);

/// \brief Waits until all work is done and threads are idle
/// \param[in] _timeout How long to wait, default to forever
/// \returns true if all work was finished
/// \remarks The return value can be false even when waiting forever if
// the WorkerPool is destructed before all work is completed
public: bool WaitForResults(
const std::chrono::steady_clock::duration &_timeout =
std::chrono::steady_clock::duration::zero());

IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \brief private implementation pointer
Expand Down
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ ign_create_core_library(
target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
PRIVATE ${DL_TARGET})

# This is required by the WorkerPool::WaitForResults(const Time &_timeout)
# TODO(anyone): IGN_DEPRECATED(4). Remove this part when the method is removed
target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE
${ignition-math${IGN_MATH_VER}_INCLUDE_DIRS})

# Handle non-Windows configuration settings
if(NOT WIN32)

Expand Down
Loading