blob: 439b9140892d259219c79196c029a7e8f3e0c1a6 [file] [log] [blame]
Alexander Afanasyev920af2f2014-01-25 22:56:11 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Named Data Networking Project
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "scheduler.hpp"
8
Alexander Afanasyev18bbf812014-01-29 01:40:23 -08009namespace nfd {
Junxiao Shic041ca32014-02-25 20:01:15 -070010namespace scheduler {
Alexander Afanasyev920af2f2014-01-25 22:56:11 -080011
Junxiao Shic041ca32014-02-25 20:01:15 -070012static shared_ptr<Scheduler> g_scheduler;
13
14Scheduler&
15getGlobalScheduler()
Alexander Afanasyev920af2f2014-01-25 22:56:11 -080016{
Junxiao Shic041ca32014-02-25 20:01:15 -070017 if (!static_cast<bool>(g_scheduler)) {
18 g_scheduler = make_shared<Scheduler>(boost::ref(getGlobalIoService()));
Alexander Afanasyev920af2f2014-01-25 22:56:11 -080019 }
Junxiao Shic041ca32014-02-25 20:01:15 -070020 return *g_scheduler;
Alexander Afanasyev920af2f2014-01-25 22:56:11 -080021}
22
23void
Junxiao Shic041ca32014-02-25 20:01:15 -070024resetGlobalScheduler()
Alexander Afanasyev920af2f2014-01-25 22:56:11 -080025{
Junxiao Shic041ca32014-02-25 20:01:15 -070026 g_scheduler.reset();
Alexander Afanasyev920af2f2014-01-25 22:56:11 -080027}
28
Junxiao Shic041ca32014-02-25 20:01:15 -070029} // namespace scheduler
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080030} // namespace nfd