Strict memory order (#306)
* Make MemoryOrdering more strict * fmt * Strict mem order for priority_tasks_gate
This commit is contained in:
@@ -464,7 +464,7 @@ impl Host {
|
||||
}
|
||||
|
||||
pub fn stop(&self, io: &IoContext<NetworkIoMessage>) {
|
||||
self.stopping.store(true, AtomicOrdering::Release);
|
||||
self.stopping.store(true, AtomicOrdering::SeqCst);
|
||||
let mut to_kill = Vec::new();
|
||||
for e in self.sessions.read().iter() {
|
||||
let mut s = e.lock();
|
||||
@@ -1168,7 +1168,7 @@ impl IoHandler<NetworkIoMessage> for Host {
|
||||
}
|
||||
|
||||
fn stream_readable(&self, io: &IoContext<NetworkIoMessage>, stream: StreamToken) {
|
||||
if self.stopping.load(AtomicOrdering::Acquire) {
|
||||
if self.stopping.load(AtomicOrdering::SeqCst) {
|
||||
return;
|
||||
}
|
||||
match stream {
|
||||
@@ -1180,7 +1180,7 @@ impl IoHandler<NetworkIoMessage> for Host {
|
||||
}
|
||||
|
||||
fn stream_writable(&self, io: &IoContext<NetworkIoMessage>, stream: StreamToken) {
|
||||
if self.stopping.load(AtomicOrdering::Acquire) {
|
||||
if self.stopping.load(AtomicOrdering::SeqCst) {
|
||||
return;
|
||||
}
|
||||
match stream {
|
||||
@@ -1191,7 +1191,7 @@ impl IoHandler<NetworkIoMessage> for Host {
|
||||
}
|
||||
|
||||
fn timeout(&self, io: &IoContext<NetworkIoMessage>, token: TimerToken) {
|
||||
if self.stopping.load(AtomicOrdering::Acquire) {
|
||||
if self.stopping.load(AtomicOrdering::SeqCst) {
|
||||
return;
|
||||
}
|
||||
match token {
|
||||
@@ -1253,7 +1253,7 @@ impl IoHandler<NetworkIoMessage> for Host {
|
||||
}
|
||||
|
||||
fn message(&self, io: &IoContext<NetworkIoMessage>, message: &NetworkIoMessage) {
|
||||
if self.stopping.load(AtomicOrdering::Acquire) {
|
||||
if self.stopping.load(AtomicOrdering::SeqCst) {
|
||||
return;
|
||||
}
|
||||
match *message {
|
||||
|
||||
@@ -73,11 +73,11 @@ impl TestProtocol {
|
||||
}
|
||||
|
||||
pub fn got_timeout(&self) -> bool {
|
||||
self.got_timeout.load(AtomicOrdering::Relaxed)
|
||||
self.got_timeout.load(AtomicOrdering::SeqCst)
|
||||
}
|
||||
|
||||
pub fn got_disconnect(&self) -> bool {
|
||||
self.got_disconnect.load(AtomicOrdering::Relaxed)
|
||||
self.got_disconnect.load(AtomicOrdering::SeqCst)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,13 +101,13 @@ impl NetworkProtocolHandler for TestProtocol {
|
||||
}
|
||||
|
||||
fn disconnected(&self, _io: &dyn NetworkContext, _peer: &PeerId) {
|
||||
self.got_disconnect.store(true, AtomicOrdering::Relaxed);
|
||||
self.got_disconnect.store(true, AtomicOrdering::SeqCst);
|
||||
}
|
||||
|
||||
/// Timer function called after a timeout created with `NetworkContext::timeout`.
|
||||
fn timeout(&self, _io: &dyn NetworkContext, timer: TimerToken) {
|
||||
assert_eq!(timer, 0);
|
||||
self.got_timeout.store(true, AtomicOrdering::Relaxed);
|
||||
self.got_timeout.store(true, AtomicOrdering::SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user