[ndnSIM] core: Partial emulation of boost::asio::io_service for NS-3
This commit assumes that ndn::Scheduler is redirected to ns3::Simulator
routines inside the ndn-cxx library.
Change-Id: Ib987f09f76a5d2103365312261fc5a2eba7024d2
diff --git a/core/global-io.cpp b/core/global-io.cpp
index 48566f6..7eb6a56 100644
--- a/core/global-io.cpp
+++ b/core/global-io.cpp
@@ -24,33 +24,31 @@
*/
#include "global-io.hpp"
-#include <boost/thread/tss.hpp>
+#include "scheduler.hpp"
namespace nfd {
-namespace scheduler {
-// defined in scheduler.cpp
+namespace detail {
+
void
-resetGlobalScheduler();
-} // namespace scheduler
-
-
-static boost::thread_specific_ptr<boost::asio::io_service> g_ioService;
-
-boost::asio::io_service&
-getGlobalIoService()
+SimulatorIo::post(const std::function<void()>& callback)
{
- if (g_ioService.get() == nullptr) {
- g_ioService.reset(new boost::asio::io_service());
- }
- return *g_ioService;
+ scheduler::schedule(time::seconds(0), callback);
}
void
-resetGlobalIoService()
+SimulatorIodispatch(const std::function<void()>& callback)
{
- scheduler::resetGlobalScheduler();
- g_ioService.reset();
+ scheduler::schedule(time::seconds(0), callback);
+}
+
+} // namespace detail
+
+detail::SimulatorIo&
+getGlobalIoService()
+{
+ static detail::SimulatorIo io;
+ return io;
}
} // namespace nfd