@ -15,7 +15,7 @@ struct StateInner
{
map : UnsafeCell < super ::map ::MemoryMapMut > ,
completion : mpsc::Sender < ( usize , usize ) > ,
completion : Mutex< mpsc::Sender < ( usize , usize ) > > ,
}
// SAFETY: The whole point of this is internal mutablility across thread boundaries.
@ -29,13 +29,13 @@ impl State
/// Create a new state from this map
#[ inline ] pub fn new ( map : super ::map ::MemoryMapMut , completion : mpsc ::Sender < ( usize , usize ) > ) -> Self
{
Self ( Arc ::new ( StateInner { map : UnsafeCell ::new ( map ) , completion } ) )
Self ( Arc ::new ( StateInner { map : UnsafeCell ::new ( map ) , completion : Mutex ::new ( completion ) } ) )
}
/// Send a completion signal for the file of this index and this size.
pub fn send_complete ( & self , idx : usize , size : usize ) -> Result < ( ) , mpsc ::SendError < ( usize , usize ) > >
{
self . 0. completion . send( ( idx , size ) )
self . 0. completion . lock( ) . unwrap ( ) . send( ( idx , size ) )
}
/// Try to consume this instance into its map. This will only succeed if there are no more references to the state than this one.