I have this toy structure I'm playing around with:
pub struct Community {
pub community_contents: RwLock<CommunityContents>,
}
pub struct CommunityContents {
pub friends: RefCell<HashMap<FriendID, FriendData>>,
pub index: RefCell<HashMap<u64, BTreeMap<FriendID, FriendData>>>,
pub authenticated: bool,
pub age: u64,
pub height: u64,
}
My theory was to have an Arc
around the RwLock
of Community
and then I could have multiple writers to the RwLock
and these writers could independently/concurrently modify the friends
and index
fields of CommunityContents
via Rc<RefCell
.
Is this even possible? Will RwLock
just not allow more than one writer at a time no matter what - in which case I should just remove the RefCells
and simplify the whole structure?