Qpid Proton C++  0.17.0
reconnect_timer.hpp
1 #ifndef PROTON_RECONNECT_TIMER_HPP
2 #define PROTON_RECONNECT_TIMER_HPP
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
27 
28 #include "./internal/export.hpp"
29 #include "./duration.hpp"
30 #include "./timestamp.hpp"
31 
32 #include <proton/type_compat.h>
33 
34 namespace proton {
35 
40 class reconnect_timer {
41  public:
42  PN_CPP_EXTERN reconnect_timer(uint32_t first = 0, int32_t max = -1, uint32_t increment = 100,
43  bool doubling = true, int32_t max_retries = -1, int32_t timeout = -1);
44 
47  PN_CPP_EXTERN void reset();
48 
53  PN_CPP_EXTERN int next_delay(timestamp now);
54 
55  private:
56  duration first_delay_;
57  duration max_delay_;
58  duration increment_;
59  bool doubling_;
60  int32_t max_retries_;
61  duration timeout_;
62  int32_t retries_;
63  duration next_delay_;
64  timestamp timeout_deadline_;
65 };
66 
67 } // proton
68 
70 
71 #endif // PROTON_RECONNECT_TIMER_HPP
The main Proton namespace.
Definition: annotation_key.hpp:30