NCBI C++ ToolKit
http_connection.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef HTTP_CONNECTION__HPP
2 #define HTTP_CONNECTION__HPP
3 
4 /* $Id: http_connection.hpp 99133 2023-02-16 18:52:33Z satskyse $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Dmitri Dmitrienko
30  *
31  * File Description:
32  *
33  */
34 
35 #include "psgs_reply.hpp"
36 #include "pending_operation.hpp"
38 #include "pubseq_gateway_types.hpp"
39 
40 
42 {
43 public:
44  CHttpConnection(size_t http_max_backlog,
45  size_t http_max_running) :
46  m_HttpMaxBacklog(http_max_backlog), m_HttpMaxRunning(http_max_running),
48  {}
49 
51 
52  void SetupMaintainTimer(uv_loop_t * tcp_worker_loop);
53  void CleanupToStop(void);
54 
55  bool IsClosed(void) const
56  {
57  return m_IsClosed;
58  }
59 
61  {
62  m_IsClosed = true;
63  x_CancelAll();
64  }
65 
67  {
68  m_IsClosed = true;
69  x_CancelAll();
70  }
71 
72  static void s_OnBeforeClosedConnection(void * data)
73  {
74  CHttpConnection * p = static_cast<CHttpConnection*>(data);
76  }
77 
78  void PeekAsync(bool chk_data_ready);
79  void ResetForReuse(void);
80  void Postpone(shared_ptr<CPSGS_Request> request,
81  shared_ptr<CPSGS_Reply> reply,
82  list<string> processor_names);
83  void ScheduleMaintain(void);
84  void DoScheduledMaintain(void);
85 
86  void OnTimer(void)
87  {
88  PeekAsync(false);
90  }
91 
92 private:
95 
96  volatile bool m_IsClosed;
98 
100  {
101  shared_ptr<CPSGS_Request> m_Request;
102  shared_ptr<CPSGS_Reply> m_Reply;
105  };
106 
107  list<SBacklogAttributes> m_BacklogRequests;
108  list<shared_ptr<CPSGS_Reply>> m_RunningRequests;
109 
110  void x_CancelAll(void);
111  void x_CancelBacklog(void);
112 
113  using running_list_iterator_t = typename list<shared_ptr<CPSGS_Reply>>::iterator;
114  using backlog_list_iterator_t = typename list<SBacklogAttributes>::iterator;
115 
118 
119  void x_RegisterPending(shared_ptr<CPSGS_Request> request,
120  shared_ptr<CPSGS_Reply> reply,
121  list<string> processor_names);
122  void x_Start(shared_ptr<CPSGS_Request> request,
123  shared_ptr<CPSGS_Reply> reply,
124  list<string> processor_names);
125 
126  void x_MaintainFinished(void);
127  void x_MaintainBacklog(void);
128 };
129 
130 #endif
131 
bool IsClosed(void) const
list< SBacklogAttributes > m_BacklogRequests
void SetupMaintainTimer(uv_loop_t *tcp_worker_loop)
void x_MaintainBacklog(void)
typename list< shared_ptr< CPSGS_Reply > >::iterator running_list_iterator_t
void DoScheduledMaintain(void)
volatile bool m_IsClosed
void PeekAsync(bool chk_data_ready)
void OnClientClosedConnection(void)
void x_Start(shared_ptr< CPSGS_Request > request, shared_ptr< CPSGS_Reply > reply, list< string > processor_names)
static void s_OnBeforeClosedConnection(void *data)
list< shared_ptr< CPSGS_Reply > > m_RunningRequests
uv_timer_t m_ScheduledMaintainTimer
void ScheduleMaintain(void)
void x_MaintainFinished(void)
void x_UnregisterBacklog(backlog_list_iterator_t &it)
void x_RegisterPending(shared_ptr< CPSGS_Request > request, shared_ptr< CPSGS_Reply > reply, list< string > processor_names)
void x_UnregisterRunning(running_list_iterator_t &it)
void OnBeforeClosedConnection(void)
void x_CancelAll(void)
CHttpConnection(size_t http_max_backlog, size_t http_max_running)
typename list< SBacklogAttributes >::iterator backlog_list_iterator_t
void CleanupToStop(void)
void Postpone(shared_ptr< CPSGS_Request > request, shared_ptr< CPSGS_Reply > reply, list< string > processor_names)
void x_CancelBacklog(void)
void ResetForReuse(void)
#define false
Definition: bool.h:36
char data[12]
Definition: iconv.c:80
psg_clock_t::time_point psg_time_point_t
shared_ptr< CPSGS_Reply > m_Reply
shared_ptr< CPSGS_Request > m_Request
Modified on Wed Sep 04 15:02:26 2024 by modify_doxy.py rev. 669887