blob: 14dadd721eb641ac5c6e3fd5d3b02095e7c48c39 [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 {
13
14class LimitedIo
15{
16public:
17 LimitedIo();
18
19 enum StopReason
20 {
21 NO_WORK,
22 EXCEED_OPS,
23 EXCEED_TIME
24 };
25
26 StopReason
27 run(int nOpsLimit, time::Duration nTimeLimit);
28
29 void
30 afterOp();
31
32private:
33 void
34 afterTimeout();
35
36public:
37 static const int UNLIMITED_OPS;
38 static const time::Duration UNLIMITED_TIME;
39
40private:
41 bool m_isRunning;
42 int m_nOpsRemaining;
43 EventId m_timeout;
44 StopReason m_reason;
45};
46
47} // namespace nfd
48
49#endif // NFD_TEST_CORE_LIMITED_IO_HPP