core: global io_service and scheduler
Scheduler and time are imported from ndn-cpp-dev.
Forwarder is using the new scheduler API.
Face system is not transitioned yet.
refs #1290
Change-Id: I5679cb50bbf9890a105f663b038f13951403c2b6
diff --git a/daemon/core/global-io.cpp b/daemon/core/global-io.cpp
new file mode 100644
index 0000000..74f1dc5
--- /dev/null
+++ b/daemon/core/global-io.cpp
@@ -0,0 +1,35 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "global-io.hpp"
+
+namespace nfd {
+
+namespace scheduler {
+// defined in scheduler.cpp
+void
+resetGlobalScheduler();
+} // namespace scheduler
+
+static shared_ptr<boost::asio::io_service> g_ioService;
+
+boost::asio::io_service&
+getGlobalIoService()
+{
+ if (!static_cast<bool>(g_ioService)) {
+ g_ioService = make_shared<boost::asio::io_service>();
+ }
+ return *g_ioService;
+}
+
+void
+resetGlobalIoService()
+{
+ scheduler::resetGlobalScheduler();
+ g_ioService.reset();
+}
+
+} // namespace nfd