Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fine-tune the Ordering for the atomic usages #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wang384670111
Copy link

SeqCst is overly restrictive. I believe that the ordering can be appropriately modified.
I think that USE_ERRORMODE is merely signal for multithreading purposes and do not synchronize with other locals. Therefore, using Relaxed ordering should suffice.

if !USE_ERRORMODE.load(Ordering::Acquire) {
let mut previous: DWORD = 0;
if unsafe { SetThreadErrorMode(ERROR_MODE, &mut previous) } == 0 {
//error. On some systems SetThreadErrorMode may not be implemented
let error = unsafe { GetLastError() };
if error == ERROR_CALL_NOT_IMPLEMENTED {
USE_ERRORMODE.store(true, Ordering::Release);
} else {
//this is an actual error
//SetErrorMode never fails. Shouldn't we use it now?
return Err(IoError::from_raw_os_error(error as i32));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant