core: add a facility to execute functions on the RIB io_service
refs #4279
Change-Id: I29222053348e5d1737d47c85a59d29280b4b791b
diff --git a/core/global-io.cpp b/core/global-io.cpp
index 48566f6..bd73244 100644
--- a/core/global-io.cpp
+++ b/core/global-io.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -34,8 +34,8 @@
resetGlobalScheduler();
} // namespace scheduler
-
static boost::thread_specific_ptr<boost::asio::io_service> g_ioService;
+static boost::asio::io_service* g_ribIoService = nullptr;
boost::asio::io_service&
getGlobalIoService()
@@ -53,4 +53,23 @@
g_ioService.reset();
}
+void
+setRibIoService(boost::asio::io_service* ribIo)
+{
+ g_ribIoService = ribIo;
+}
+
+boost::asio::io_service&
+getRibIoService()
+{
+ BOOST_ASSERT(g_ribIoService != nullptr);
+ return *g_ribIoService;
+}
+
+void
+runOnRibIoService(const std::function<void()>& f)
+{
+ getRibIoService().post(f);
+}
+
} // namespace nfd