From 57655d8153c3976ce14985f67417e2dc1a50095e Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Tue, 13 Feb 2018 13:47:59 +1300 Subject: [PATCH] Use AtomicUsize properly doing a read+write on an atomic int will lose updates from other threads. --- guide/src/qs_4.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/guide/src/qs_4.md b/guide/src/qs_4.md index e7193ae55..a8424a4a0 100644 --- a/guide/src/qs_4.md +++ b/guide/src/qs_4.md @@ -89,8 +89,7 @@ impl Handler for MyHandler { /// Handle request fn handle(&mut self, req: HttpRequest) -> Self::Result { - let num = self.0.load(Ordering::Relaxed) + 1; - self.0.store(num, Ordering::Relaxed); + self.0.fetch_add(1, Ordering::Relaxed); httpcodes::HTTPOk.into() } }