1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-28 09:42:40 +01:00

Use AtomicUsize properly

doing a read+write on an atomic int will lose updates from other threads.
This commit is contained in:
Robert Collins 2018-02-13 13:47:59 +13:00 committed by GitHub
parent 335ca8ff33
commit 57655d8153
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,8 +89,7 @@ impl<S> Handler<S> for MyHandler {
/// Handle request /// Handle request
fn handle(&mut self, req: HttpRequest<S>) -> Self::Result { fn handle(&mut self, req: HttpRequest<S>) -> Self::Result {
let num = self.0.load(Ordering::Relaxed) + 1; self.0.fetch_add(1, Ordering::Relaxed);
self.0.store(num, Ordering::Relaxed);
httpcodes::HTTPOk.into() httpcodes::HTTPOk.into()
} }
} }