|
- #pragma once
-
- #include <asyncpp.h>
-
- struct test_delay final
- : public asyncpp::base_future<int&, test_delay>
- {
- public:
- using value_type = int&;
- using this_type = test_delay;
- using base_future_type = base_future<value_type, this_type>;
- using result_type = typename base_future_type::result_type;
-
- public:
- int const _delay { 5 };
- int _count { 0 };
-
- public:
- test_delay(int p_delay, int p_count)
- : _delay(p_delay)
- , _count(p_count)
- { }
-
- inline result_type poll()
- {
- if (_count >= _delay)
- return result_type::ready(_count);
-
- ++_count;
-
- return result_type::not_ready();
- }
- };
|