Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 1 | /* -*- 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 | |
| 12 | namespace nfd { |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 13 | namespace tests { |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 14 | |
| 15 | class LimitedIo |
| 16 | { |
| 17 | public: |
| 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 | |
| 33 | private: |
| 34 | void |
| 35 | afterTimeout(); |
| 36 | |
| 37 | public: |
| 38 | static const int UNLIMITED_OPS; |
| 39 | static const time::Duration UNLIMITED_TIME; |
| 40 | |
| 41 | private: |
| 42 | bool m_isRunning; |
| 43 | int m_nOpsRemaining; |
| 44 | EventId m_timeout; |
| 45 | StopReason m_reason; |
| 46 | }; |
| 47 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 48 | } // namespace tests |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 49 | } // namespace nfd |
| 50 | |
| 51 | #endif // NFD_TEST_CORE_LIMITED_IO_HPP |