File tree 1 file changed +34
-1
lines changed
Sources/AsyncHTTPClient/ConnectionPool
1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change 15
15
import NIO
16
16
17
17
enum HTTPConnectionPool {
18
- struct Connection : Equatable {
18
+ struct Connection : Hashable {
19
19
typealias ID = Int
20
20
21
21
private enum Reference {
@@ -91,5 +91,38 @@ enum HTTPConnectionPool {
91
91
// return false
92
92
}
93
93
}
94
+
95
+ func hash( into hasher: inout Hasher ) {
96
+ switch self . _ref {
97
+ case . __testOnly_connection( let id, let eventLoop) :
98
+ hasher. combine ( id)
99
+ hasher. combine ( eventLoop. id)
100
+ }
101
+ }
102
+ }
103
+ }
104
+
105
+ struct EventLoopID : Hashable {
106
+ private var id : Identifier
107
+
108
+ private enum Identifier : Hashable {
109
+ case objectIdentifier( ObjectIdentifier )
110
+ case __testOnly_fakeID( Int )
94
111
}
112
+
113
+ init ( _ eventLoop: EventLoop ) {
114
+ self . init ( . objectIdentifier( ObjectIdentifier ( eventLoop) ) )
115
+ }
116
+
117
+ private init ( _ id: Identifier ) {
118
+ self . id = id
119
+ }
120
+
121
+ static func __testOnly_fakeID( _ id: Int ) -> EventLoopID {
122
+ return EventLoopID ( . __testOnly_fakeID( id) )
123
+ }
124
+ }
125
+
126
+ extension EventLoop {
127
+ var id : EventLoopID { EventLoopID ( self ) }
95
128
}
You can’t perform that action at this time.
0 commit comments