Remove git dependency

This commit is contained in:
Waffle 2021-01-12 13:13:53 +03:00
parent 8e011b7e60
commit 6abf571c96
2 changed files with 25 additions and 27 deletions

View file

@ -34,8 +34,7 @@ thiserror = "1.0.20"
once_cell = "1.5.0"
never = "0.1.0"
# FIXME(waffle): use crates.io once published
vecrem = { git = "https://github.com/WaffleLapkin/vecrem", rev = "6b9b6f42342df8b75548c6ed387072ff235429b1" }
vecrem = { version = "0.1", optional = true }
[features]
default = []
@ -47,7 +46,7 @@ default = []
nightly = []
# Throttling bot adaptor
throttle = []
throttle = ["vecrem"]
# CacheMe bot adaptor
cache_me = []

View file

@ -267,34 +267,33 @@ async fn worker(limits: Limits, mut queue_rx: mpsc::Receiver<(Id, Sender<Never>)
*hchats_s.entry(*chat).or_insert(0) += 1;
}
let mut queue_rem = queue.removing();
while let Some(entry) = queue_rem.next() {
let chat = &entry.value().0;
let cond = {
hchats_s.get(chat).copied().unwrap_or(0) < limits.chat_s
&& hchats.get(chat).copied().unwrap_or(0) < limits.chat_m
};
{
let mut queue_rem = queue.removing();
while let Some(entry) = queue_rem.next() {
let chat = &entry.value().0;
let cond = {
hchats_s.get(chat).copied().unwrap_or(0) < limits.chat_s
&& hchats.get(chat).copied().unwrap_or(0) < limits.chat_m
};
if cond {
{
*hchats_s.entry(*chat).or_insert(0) += 1;
*hchats.entry(*chat).or_insert(0) += 1;
history.push_back((*chat, Instant::now()));
if cond {
{
*hchats_s.entry(*chat).or_insert(0) += 1;
*hchats.entry(*chat).or_insert(0) += 1;
history.push_back((*chat, Instant::now()));
}
// This will close the channel unlocking associated request
drop(entry.remove());
// We've "sent" 1 request, so now we can send 1 less
allowed -= 1;
if allowed == 0 {
break;
}
}
// This will close the channel unlocking associated request
drop(entry.remove());
// We've "sent" 1 request, so now we can send 1 less
allowed -= 1;
if allowed == 0 {
break;
}
} else {
entry.skip();
}
}
drop(queue_rem);
// It's easier to just recompute last second stats, instead of keeping
// track of it alongside with minute stats, so we just throw this away.