blob: 2fdb6edfcdcb6882ba759daea81c6e69cbd8b981 [file] [log] [blame]
Davide Pesaventocf7db2f2019-03-24 23:17:28 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
Davide Pesaventoa9e1ab22023-10-02 22:10:45 -04003 * Copyright (c) 2014-2023, Regents of the University of California,
Davide Pesaventocf7db2f2019-03-24 23:17:28 -04004 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
10 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#include "tests/daemon/global-io-fixture.hpp"
Davide Pesavento2cae8ca2019-04-18 20:48:05 -040027#include "common/global.hpp"
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040028
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040029namespace nfd::tests {
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040030
31GlobalIoFixture::GlobalIoFixture()
32 : g_io(getGlobalIoService())
33{
34}
35
36GlobalIoFixture::~GlobalIoFixture()
37{
38 resetGlobalIoService();
39}
40
Junxiao Shidf1dc652019-08-30 19:03:19 +000041size_t
42GlobalIoFixture::pollIo()
43{
44 if (g_io.stopped()) {
Junxiao Shidf1dc652019-08-30 19:03:19 +000045 g_io.restart();
Junxiao Shidf1dc652019-08-30 19:03:19 +000046 }
47 return g_io.poll();
48}
49
Davide Pesavento21353752020-11-20 00:43:44 -050050void
51GlobalIoTimeFixture::afterTick()
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040052{
Davide Pesavento21353752020-11-20 00:43:44 -050053 pollIo();
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040054}
55
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040056} // namespace nfd::tests