MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

Global.hxx
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2008-2016 Max Kellermann <max.kellermann@gmail.com>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20 * FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 * OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #ifndef CURL_GLOBAL_HXX
31 #define CURL_GLOBAL_HXX
32
33 #include "Multi.hxx"
34 #include "event/TimeoutMonitor.hxx"
35 #include "event/DeferredMonitor.hxx"
36
37 class CurlSocket;
38 class CurlRequest;
39
43 class CurlGlobal final : TimeoutMonitor, DeferredMonitor {
44 CurlMulti multi;
45
46 public:
47 explicit CurlGlobal(EventLoop &_loop);
48
49 using TimeoutMonitor::GetEventLoop;
50
51 void Add(CURL *easy, CurlRequest &request);
52 void Remove(CURL *easy);
53
59 void ReadInfo();
60
61 void Assign(curl_socket_t fd, CurlSocket &cs) {
62 curl_multi_assign(multi.Get(), fd, &cs);
63 }
64
65 void SocketAction(curl_socket_t fd, int ev_bitmask);
66
67 void InvalidateSockets() {
68 SocketAction(CURL_SOCKET_TIMEOUT, 0);
69 }
70
76 void ResumeSockets() {
77 int running_handles;
78 curl_multi_socket_all(multi.Get(), &running_handles);
79 }
80
81 private:
82 void UpdateTimeout(long timeout_ms);
83 static int TimerFunction(CURLM *global, long timeout_ms, void *userp);
84
85 /* virtual methods from class TimeoutMonitor */
86 void OnTimeout() override;
87
88 /* virtual methods from class DeferredMonitor */
89 void RunDeferred() override;
90 };
91
92 #endif
CurlGlobal::InvalidateSockets
void InvalidateSockets()
Definition: Global.hxx:67
TimeoutMonitor
This class monitors a timeout.
Definition: TimeoutMonitor.hxx:37
EventLoop
An event loop that polls for events on file/socket descriptors.
Definition: Loop.hxx:51
DeferredMonitor
Defer execution of an event into an EventLoop.
Definition: DeferredMonitor.hxx:32
CurlGlobal::Add
void Add(CURL *easy, CurlRequest &request)
TimeoutMonitor::GetEventLoop
EventLoop & GetEventLoop()
Definition: TimeoutMonitor.hxx:53
CurlRequest
Definition: Request.hxx:44
CurlMulti
An OO wrapper for a "CURLM*" (a libCURL "multi" handle).
Definition: Multi.hxx:42
CurlGlobal::SocketAction
void SocketAction(curl_socket_t fd, int ev_bitmask)
TimeoutMonitor.hxx
Multi.hxx
DeferredMonitor.hxx
CurlGlobal::ReadInfo
void ReadInfo()
Check for finished HTTP responses.
CurlGlobal::Remove
void Remove(CURL *easy)
CurlGlobal::CurlGlobal
CurlGlobal(EventLoop &_loop)
CurlGlobal::ResumeSockets
void ResumeSockets()
This is a kludge to allow pausing/resuming a stream with libcurl < 7.32.0.
Definition: Global.hxx:76
CurlGlobal
Manager for the global CURLM object.
Definition: Global.hxx:43
CurlGlobal::Assign
void Assign(curl_socket_t fd, CurlSocket &cs)
Definition: Global.hxx:61