blob: 7fb4f7082bb946e99ca0cd3b1c4e706f587e11fa [file] [log] [blame]
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -07001/* -*- 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#ifndef NFD_TEST_CORE_LIMITED_IO_HPP
8#define NFD_TEST_CORE_LIMITED_IO_HPP
9
10#include "core/scheduler.hpp"
11
12namespace nfd {
Junxiao Shid9ee45c2014-02-27 15:38:11 -070013namespace tests {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070014
15class LimitedIo
16{
17public:
18 LimitedIo();
19
20 enum StopReason
21 {
22 NO_WORK,
23 EXCEED_OPS,
24 EXCEED_TIME
25 };
26
27 StopReason
28 run(int nOpsLimit, time::Duration nTimeLimit);
29
30 void
31 afterOp();
32
33private:
34 void
35 afterTimeout();
36
37public:
38 static const int UNLIMITED_OPS;
39 static const time::Duration UNLIMITED_TIME;
40
41private:
42 bool m_isRunning;
43 int m_nOpsRemaining;
44 EventId m_timeout;
45 StopReason m_reason;
46};
47
Junxiao Shid9ee45c2014-02-27 15:38:11 -070048} // namespace tests
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070049} // namespace nfd
50
51#endif // NFD_TEST_CORE_LIMITED_IO_HPP