MobileCoin: Synchronization primitives for SGX enclaves

Project ChatLicenseTargetCrates.ioDocs StatusDependency Status

Synchronization primitives for SGX enclaves.

The available primitives are meant to mimic the behavior of std::sync. Only the primitives whose behavior can be supported in SGX enclaves are supported.

Examples

To have code that works with both std::sync and mc-sgx-sync.

```rust

[cfg(feature = "sgx")]

use mcsgxsync::Mutex;

[cfg(not(feature = "sgx"))]

use std::sync::Mutex;

let mutex = Mutex::new(5);

{ let mut data = lock.lock().unwrap(); data += 1; assert_eq!(data, 6); } // lock is dropped here ```

Developer Notes

The modules are implemented to mimic the layout of std::sync.

module hierarchy

mc-sgx-sync could depend on mc-sgx-tstdc-sys and call the C implementation directly. This is how many of the sys modules in the rust source are implemented. The choice to depend on mc-sgx-tstdc was made to be consistent with the use of other mc-sgx-<lib_wrapper>-sys crates. The mc-sgx-<lib_wrapper> crates provides idiomatic rust interfaces over the C API and are usually the only crates that directly depend on the mc-sgx-<lib_wrapper>-sys crates.