AWS SDK for C++  0.14.3
AWS SDK for C++
CurlHandleContainer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #pragma once
17 
19 
20 #include <utility>
21 #include <mutex>
22 #include <condition_variable>
23 #include <curl/curl.h>
24 
25 namespace Aws
26 {
27 namespace Http
28 {
29 
37 {
38 public:
43  CurlHandleContainer(unsigned maxSize = 50, long requestTimeout = 3000, long connectTimeout = 1000);
45 
49  CURL* AcquireCurlHandle();
54  void ReleaseCurlHandle(CURL* handle);
55 
56 private:
58  const CurlHandleContainer& operator = (const CurlHandleContainer&) = delete;
59  CurlHandleContainer(const CurlHandleContainer&&) = delete;
60  const CurlHandleContainer& operator = (const CurlHandleContainer&&) = delete;
61 
62  bool CheckAndGrowPool();
63  void SetDefaultOptionsOnHandle(void* handle);
64 
65  Aws::Stack<CURL*> m_handleContainer;
66  std::mutex m_handleContainerMutex;
67  std::condition_variable m_conditionVariable;
68  unsigned m_maxPoolSize;
69  unsigned long m_requestTimeout;
70  unsigned long m_connectTimeout;
71  unsigned m_poolSize;
72 };
73 
74 } // namespace Http
75 } // namespace Aws
76 
void ReleaseCurlHandle(CURL *handle)
std::stack< T, Deque< T > > Stack
Definition: AWSStack.h:29
CurlHandleContainer(unsigned maxSize=50, long requestTimeout=3000, long connectTimeout=1000)
JSON (JavaScript Object Notation).