You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
label = "Shards (Each is a thread, one per 2500 Discord guilds)";
22
+
node [style=filled,color=2]
23
+
"Cluster" -> "Event Loop"
24
+
"Event Loop" -> "HTTP(S) requests"
25
+
"Event Loop" -> "Voice Sessions"
26
+
"Event Loop" -> "Shards"
27
+
"Shards" -> "Websocket Events"
28
+
label = "(2)";
29
29
}
30
30
31
-
subgraph cluster_1 {
32
-
style=filled
33
-
color=lightgrey;
34
-
node [style=filled,color=4]
35
-
"REST Requests"
36
-
"Request In Queue 1"
37
-
"Request In Queue 2"
38
-
"Request In Queue 3..."
39
-
"Request Out Queue"
40
-
label = "REST Requests (Each in queue, and the out queue, are threads)"
41
-
}
42
31
43
-
subgraph cluster_3 {
44
-
style=filled
32
+
subgraph cluster_0 {
33
+
style=filled;
45
34
color=lightgrey;
46
35
node [style=filled,color=4]
47
-
"Discord Events" [style=filled,color=4]
48
-
"User Callback Functions"
49
-
label = "Events and Callbacks"
36
+
"Voice Sessions" -> "Websocket Events"
37
+
"HTTP(S) requests" -> "Thread Pool (4..n threads)"
38
+
"Websocket Events" -> "Thread Pool (4..n threads)"
39
+
"Thread Pool (4..n threads)"
40
+
label = "(3)";
50
41
}
51
42
52
43
"Cluster" [shape=rect]
53
-
"REST Requests" [shape=rect]
54
-
"Request In Queue 1" [shape=rect]
55
-
"Request In Queue 2" [shape=rect]
56
-
"Request In Queue 3..." [shape=rect]
57
-
"Shard 1" [shape=rect]
58
-
"Shard 2" [shape=rect]
59
-
"Shard 3..." [shape=rect]
60
-
"Request Out Queue" [shape=rect]
61
-
"Discord Events" [shape=rect]
62
-
"User Callback Functions" [shape=rect]
44
+
"Thread Pool (4..n threads)" [shape=rect]
45
+
"HTTP(S) requests" [shape=rect]
46
+
"Shards" [shape=rect]
47
+
"Websocket Events" [shape=rect]
48
+
"Event Loop" [shape=rect]
49
+
"Voice Sessions" [shape=rect]
63
50
64
-
"Cluster" -> "REST Requests"
65
-
"Shard 1" -> "Discord Events"
66
-
"Shard 2" -> "Discord Events"
67
-
"Shard 3..." -> "Discord Events"
68
-
"Your Program" -> "Cluster"
69
-
"Cluster" -> "Shard 1"
70
-
"Cluster" -> "Shard 2"
71
-
"Cluster" -> "Shard 3..."
72
-
"REST Requests" -> "Request In Queue 1"
73
-
"REST Requests" -> "Request In Queue 2"
74
-
"REST Requests" -> "Request In Queue 3..."
75
-
"Request In Queue 1" -> "Request Out Queue"
76
-
"Request In Queue 2" -> "Request Out Queue"
77
-
"Request In Queue 3..." -> "Request Out Queue"
78
-
"Request Out Queue" -> "User Callback Functions"
79
-
"User Callback Functions" -> "Your Program"
80
51
}
81
52
\enddot
53
+
54
+
## Details
55
+
56
+
1. User Code - No assumptions are made about how your program threads, if at all.
57
+
2. The event loop manages all socket IO for the cluster. If you start the cluster with dpp::st_return this will run under its own thread, otherwise if you use dpp::st_wait it will run in the same thread as the caller of the dpp::cluster::start method.
58
+
The event loop will be either poll, epoll or kqueue based depending on your system capabilities. You should always start a cluster after forking, if your program forks, as various types of IO loop cannot be inherited by a forked process.
59
+
3. Set thread pool size via cluster constructor. Thread pool uses a priority queue and defaults in size to half the system concurrency value. Every callback or completed coroutine ends up executing here. The minimum concurrency of this pool is 4.
0 commit comments