forked from cawka/ndn.cxx
diff --git a/scheduler/one-time-task.cc b/scheduler/one-time-task.cc
new file mode 100644
index 0000000..b3082af
--- /dev/null
+++ b/scheduler/one-time-task.cc
@@ -0,0 +1,43 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013, Regents of the University of California
+ *                     Alexander Afanasyev
+ *                     Zhenkai Zhu
+ *
+ * BSD license, See the LICENSE file for more information
+ *
+ * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "one-time-task.h"
+#include "scheduler.h"
+
+OneTimeTask::OneTimeTask(const Callback &callback, const Tag &tag, const SchedulerPtr &scheduler, double delay)
+            : Task(callback, tag, scheduler)
+{
+  setTv(delay);
+}
+
+void
+OneTimeTask::run()
+{
+  if (!m_invoked)
+  {
+    m_callback();
+    m_invoked = true;
+    deregisterSelf();
+  }
+}
+
+void
+OneTimeTask::deregisterSelf()
+{
+  m_scheduler->deleteTask(m_tag);
+}
+
+void
+OneTimeTask::reset()
+{
+  m_invoked = false;
+}