Unverified Commit fb6b34be authored by David's avatar David Committed by GitHub
Browse files

Use SeqCst everywhere (#289)

I went over all the atomic operations and realised I could not convince myself that all uses of `Relaxed` were ok, so better safe than sorry: let's switch to `SeqCst`.
parent c450f106
......@@ -64,7 +64,7 @@ impl Client for HttpClient {
R: DeserializeOwned,
{
// NOTE: `fetch_add` wraps on overflow which is intended.
let id = self.request_id.fetch_add(1, Ordering::Relaxed);
let id = self.request_id.fetch_add(1, Ordering::SeqCst);
let request = JsonRpcCallSer::new(Id::Number(id), method, params);
let body = self
......
......@@ -135,7 +135,7 @@ impl RequestIdGuard {
/// Fails if request limit has been exceeded.
fn next_request_id(&self) -> Result<u64, Error> {
self.get_slot()?;
let id = self.current_id.fetch_add(1, Ordering::Relaxed);
let id = self.current_id.fetch_add(1, Ordering::SeqCst);
Ok(id)
}
......@@ -146,7 +146,7 @@ impl RequestIdGuard {
self.get_slot()?;
let mut batch = Vec::with_capacity(len);
for _ in 0..len {
batch.push(self.current_id.fetch_add(1, Ordering::Relaxed));
batch.push(self.current_id.fetch_add(1, Ordering::SeqCst));
}
Ok(batch)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment