Closed japaric closed 7 years ago
@homunkulus r+
:pushpin: Commit 69a7ffd has been approved by japaric
:hourglass: Testing commit 69a7ffd with merge 69a7ffd...
:broken_heart: Test failed - status-travis
Error: Download failed on Cask 'gcc-arm-embedded' with message: Download failed: https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update/+download/gcc-arm-none-eabi-5_4-2016q3-20160926-mac.tar.bz2
Network error
@homunkulus retry
@homunkulus r+
:pushpin: Commit ddbfd92 has been approved by japaric
:hourglass: Testing commit ddbfd92 with merge ddbfd92...
:sunny: Test successful - status-travis Approved by: japaric Pushing ddbfd92b6b487ca5f90fd859a62c61c6bbe04b1a to master...
Awesome!
this commit allow lock-less memory safe data sharing between the "main" context, the
setup
/loop
functions, and cloud functions through theResource
abstraction.Resource
s are global variables that are safe to access from different contexts. Safety is enforced in two ways:Single context memory safety: The
Resource.access{,_mut}
methods take a "context" token,App
orCloud
, to preserve Rust borrowing rules: only one mutable reference (&mut -
) OR several shared references (&-
) may exist at any given time. This rule prevents pointer invalidation. This is the kind of problem we prevent at compile time:Memory safety during preemption: If SYSTEM_THREAD is not enabled, which is our case, then cloud functions can only preempt the main context,
loop
/setup
, when theApp.delay_ms
method is called. To ensure no pointer invalidation occurs in that case aApp.delay_ms
call won't compile if there are outstanding borrows to resources in the current context. This is the kind of problem we prevent at compile time:cc @dbrgn the function and variable examples are now fully safe