aboutsummaryrefslogtreecommitdiff
path: root/externals/ace/Countdown_Time.cpp
diff options
context:
space:
mode:
authorXanadu <none@none>2010-07-20 02:49:28 +0200
committerXanadu <none@none>2010-07-20 02:49:28 +0200
commit79622802f397258ee0f34327ba3ae6977ca3e7ff (patch)
tree1868946c234ab9ee256a6b7766a15713eae94235 /externals/ace/Countdown_Time.cpp
parent7dd2dc91816ab8b3bc3b99a1b1c99c7ea314d5a8 (diff)
parentf906976837502fa5aa81b982b901d1509f5aa0c4 (diff)
Merge. Revision history for source files should be all back now.
--HG-- branch : trunk rename : sql/CMakeLists.txt => sql/tools/CMakeLists.txt rename : src/server/game/Pools/PoolHandler.cpp => src/server/game/Pools/PoolMgr.cpp rename : src/server/game/Pools/PoolHandler.h => src/server/game/Pools/PoolMgr.h rename : src/server/game/PrecompiledHeaders/NixCorePCH.cpp => src/server/game/PrecompiledHeaders/gamePCH.cpp rename : src/server/game/PrecompiledHeaders/NixCorePCH.h => src/server/game/PrecompiledHeaders/gamePCH.h
Diffstat (limited to 'externals/ace/Countdown_Time.cpp')
-rw-r--r--externals/ace/Countdown_Time.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/externals/ace/Countdown_Time.cpp b/externals/ace/Countdown_Time.cpp
new file mode 100644
index 00000000000..d76a0fa4cf5
--- /dev/null
+++ b/externals/ace/Countdown_Time.cpp
@@ -0,0 +1,59 @@
+#include "ace/Countdown_Time.h"
+#include "ace/OS_NS_sys_time.h"
+
+ACE_RCSID (ace,
+ Countdown_Time,
+ "$Id: Countdown_Time.cpp 85382 2009-05-19 06:52:56Z johnnyw $")
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Countdown_Time.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_Countdown_Time::ACE_Countdown_Time (ACE_Time_Value *max_wait_time)
+ : max_wait_time_ (max_wait_time),
+ stopped_ (false)
+{
+ this->start ();
+}
+
+ACE_Countdown_Time::~ACE_Countdown_Time (void)
+{
+ this->stop ();
+}
+
+void
+ACE_Countdown_Time::start (void)
+{
+ if (this->max_wait_time_ != 0)
+ {
+ this->start_time_ = ACE_OS::gettimeofday ();
+ this->stopped_ = false;
+ }
+}
+
+void
+ACE_Countdown_Time::stop (void)
+{
+ if (this->max_wait_time_ != 0 && !this->stopped_)
+ {
+ ACE_Time_Value const elapsed_time =
+ ACE_OS::gettimeofday () - this->start_time_;
+
+ if (elapsed_time >= ACE_Time_Value::zero &&
+ *this->max_wait_time_ > elapsed_time)
+ {
+ *this->max_wait_time_ -= elapsed_time;
+ }
+ else
+ {
+ // Used all of timeout.
+ *this->max_wait_time_ = ACE_Time_Value::zero;
+ // errno = ETIME;
+ }
+ this->stopped_ = true;
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL