@@ -6,8 +6,8 @@ use torrust_tracker_primitives::torrent_metrics::TorrentsMetrics;
6
6
use torrust_tracker_primitives:: { peer, DurationSinceUnixEpoch , PersistentTorrents } ;
7
7
use torrust_tracker_torrent_repository:: repository:: { Repository as _, RepositoryAsync as _} ;
8
8
use torrust_tracker_torrent_repository:: {
9
- EntrySingle , TorrentsRwLockStd , TorrentsRwLockStdMutexStd , TorrentsRwLockStdMutexTokio , TorrentsRwLockTokio ,
10
- TorrentsRwLockTokioMutexStd , TorrentsRwLockTokioMutexTokio , TorrentsSkipMapMutexStd ,
9
+ EntrySingle , TorrentsDashMapMutexStd , TorrentsRwLockStd , TorrentsRwLockStdMutexStd , TorrentsRwLockStdMutexTokio ,
10
+ TorrentsRwLockTokio , TorrentsRwLockTokioMutexStd , TorrentsRwLockTokioMutexTokio , TorrentsSkipMapMutexStd ,
11
11
} ;
12
12
13
13
#[ derive( Debug ) ]
@@ -19,6 +19,7 @@ pub(crate) enum Repo {
19
19
RwLockTokioMutexStd ( TorrentsRwLockTokioMutexStd ) ,
20
20
RwLockTokioMutexTokio ( TorrentsRwLockTokioMutexTokio ) ,
21
21
SkipMapMutexStd ( TorrentsSkipMapMutexStd ) ,
22
+ DashMapMutexStd ( TorrentsDashMapMutexStd ) ,
22
23
}
23
24
24
25
impl Repo {
@@ -31,6 +32,7 @@ impl Repo {
31
32
Repo :: RwLockTokioMutexStd ( repo) => Some ( repo. get ( key) . await ?. lock ( ) . unwrap ( ) . clone ( ) ) ,
32
33
Repo :: RwLockTokioMutexTokio ( repo) => Some ( repo. get ( key) . await ?. lock ( ) . await . clone ( ) ) ,
33
34
Repo :: SkipMapMutexStd ( repo) => Some ( repo. get ( key) ?. lock ( ) . unwrap ( ) . clone ( ) ) ,
35
+ Repo :: DashMapMutexStd ( repo) => Some ( repo. get ( key) ?. lock ( ) . unwrap ( ) . clone ( ) ) ,
34
36
}
35
37
}
36
38
@@ -43,6 +45,7 @@ impl Repo {
43
45
Repo :: RwLockTokioMutexStd ( repo) => repo. get_metrics ( ) . await ,
44
46
Repo :: RwLockTokioMutexTokio ( repo) => repo. get_metrics ( ) . await ,
45
47
Repo :: SkipMapMutexStd ( repo) => repo. get_metrics ( ) ,
48
+ Repo :: DashMapMutexStd ( repo) => repo. get_metrics ( ) ,
46
49
}
47
50
}
48
51
@@ -82,6 +85,11 @@ impl Repo {
82
85
. iter ( )
83
86
. map ( |( i, t) | ( * i, t. lock ( ) . expect ( "it should get a lock" ) . clone ( ) ) )
84
87
. collect ( ) ,
88
+ Repo :: DashMapMutexStd ( repo) => repo
89
+ . get_paginated ( pagination)
90
+ . iter ( )
91
+ . map ( |( i, t) | ( * i, t. lock ( ) . expect ( "it should get a lock" ) . clone ( ) ) )
92
+ . collect ( ) ,
85
93
}
86
94
}
87
95
@@ -94,6 +102,7 @@ impl Repo {
94
102
Repo :: RwLockTokioMutexStd ( repo) => repo. import_persistent ( persistent_torrents) . await ,
95
103
Repo :: RwLockTokioMutexTokio ( repo) => repo. import_persistent ( persistent_torrents) . await ,
96
104
Repo :: SkipMapMutexStd ( repo) => repo. import_persistent ( persistent_torrents) ,
105
+ Repo :: DashMapMutexStd ( repo) => repo. import_persistent ( persistent_torrents) ,
97
106
}
98
107
}
99
108
@@ -106,6 +115,7 @@ impl Repo {
106
115
Repo :: RwLockTokioMutexStd ( repo) => Some ( repo. remove ( key) . await ?. lock ( ) . unwrap ( ) . clone ( ) ) ,
107
116
Repo :: RwLockTokioMutexTokio ( repo) => Some ( repo. remove ( key) . await ?. lock ( ) . await . clone ( ) ) ,
108
117
Repo :: SkipMapMutexStd ( repo) => Some ( repo. remove ( key) ?. lock ( ) . unwrap ( ) . clone ( ) ) ,
118
+ Repo :: DashMapMutexStd ( repo) => Some ( repo. remove ( key) ?. lock ( ) . unwrap ( ) . clone ( ) ) ,
109
119
}
110
120
}
111
121
@@ -118,6 +128,7 @@ impl Repo {
118
128
Repo :: RwLockTokioMutexStd ( repo) => repo. remove_inactive_peers ( current_cutoff) . await ,
119
129
Repo :: RwLockTokioMutexTokio ( repo) => repo. remove_inactive_peers ( current_cutoff) . await ,
120
130
Repo :: SkipMapMutexStd ( repo) => repo. remove_inactive_peers ( current_cutoff) ,
131
+ Repo :: DashMapMutexStd ( repo) => repo. remove_inactive_peers ( current_cutoff) ,
121
132
}
122
133
}
123
134
@@ -130,6 +141,7 @@ impl Repo {
130
141
Repo :: RwLockTokioMutexStd ( repo) => repo. remove_peerless_torrents ( policy) . await ,
131
142
Repo :: RwLockTokioMutexTokio ( repo) => repo. remove_peerless_torrents ( policy) . await ,
132
143
Repo :: SkipMapMutexStd ( repo) => repo. remove_peerless_torrents ( policy) ,
144
+ Repo :: DashMapMutexStd ( repo) => repo. remove_peerless_torrents ( policy) ,
133
145
}
134
146
}
135
147
@@ -146,6 +158,7 @@ impl Repo {
146
158
Repo :: RwLockTokioMutexStd ( repo) => repo. update_torrent_with_peer_and_get_stats ( info_hash, peer) . await ,
147
159
Repo :: RwLockTokioMutexTokio ( repo) => repo. update_torrent_with_peer_and_get_stats ( info_hash, peer) . await ,
148
160
Repo :: SkipMapMutexStd ( repo) => repo. update_torrent_with_peer_and_get_stats ( info_hash, peer) ,
161
+ Repo :: DashMapMutexStd ( repo) => repo. update_torrent_with_peer_and_get_stats ( info_hash, peer) ,
149
162
}
150
163
}
151
164
@@ -172,6 +185,9 @@ impl Repo {
172
185
Repo :: SkipMapMutexStd ( repo) => {
173
186
repo. torrents . insert ( * info_hash, torrent. into ( ) ) ;
174
187
}
188
+ Repo :: DashMapMutexStd ( repo) => {
189
+ repo. torrents . insert ( * info_hash, torrent. into ( ) ) ;
190
+ }
175
191
} ;
176
192
self . get ( info_hash) . await
177
193
}
0 commit comments