@@ -75,13 +75,13 @@ impl Factor for BlobStoreFactor {
7575 let closure = type_annotate ( move |data| {
7676 let ( state, table) = get_data_with_table ( data) ;
7777 BlobStoreDispatch :: new (
78- state. allowed_containers . clone ( ) ,
79- state. container_manager . clone ( ) ,
78+ & state. allowed_containers ,
79+ state. container_manager . as_ref ( ) ,
8080 table,
81- state. containers . clone ( ) ,
82- state. incoming_values . clone ( ) ,
83- state. outgoing_values . clone ( ) ,
84- state. object_names . clone ( ) ,
81+ & state. containers ,
82+ & state. incoming_values ,
83+ & state. outgoing_values ,
84+ & state. object_names ,
8585 )
8686 } ) ;
8787 let linker = ctx. linker ( ) ;
@@ -141,10 +141,10 @@ impl Factor for BlobStoreFactor {
141141 Ok ( InstanceBuilder {
142142 container_manager : app_state. container_manager . clone ( ) ,
143143 allowed_containers,
144- containers : Arc :: new ( RwLock :: new ( Table :: new ( capacity) ) ) ,
145- incoming_values : Arc :: new ( RwLock :: new ( Table :: new ( capacity) ) ) ,
146- object_names : Arc :: new ( RwLock :: new ( Table :: new ( capacity) ) ) ,
147- outgoing_values : Arc :: new ( RwLock :: new ( Table :: new ( capacity) ) ) ,
144+ containers : RwLock :: new ( Table :: new ( capacity) ) ,
145+ incoming_values : RwLock :: new ( Table :: new ( capacity) ) ,
146+ object_names : RwLock :: new ( Table :: new ( capacity) ) ,
147+ outgoing_values : RwLock :: new ( Table :: new ( capacity) ) ,
148148 } )
149149 }
150150}
@@ -170,16 +170,12 @@ pub struct InstanceBuilder {
170170 ///
171171 /// For the different interfaces to agree on their resource tables, each closure
172172 /// needs to derive the same resource table from the InstanceBuilder.
173- /// The only* way that works is for the InstanceBuilder to set up all
174- /// the resource tables, and Arc-RwLock them so that each clone gets
175- /// the same one.
176- ///
177- /// * TODO: for 'only', read 'or maybe we can do some shenanigans with borrowing
178- /// from the InstanceBuilder/instance state'
179- containers : Arc < RwLock < Table < Arc < dyn Container > > > > ,
180- incoming_values : Arc < RwLock < Table < Box < dyn IncomingData > > > > ,
181- outgoing_values : Arc < RwLock < Table < host:: OutgoingValue > > > ,
182- object_names : Arc < RwLock < Table < Box < dyn ObjectNames > > > > ,
173+ /// So the InstanceBuilder (which is also the instance state) sets up all the resource
174+ /// tables and RwLocks them, then the dispatch object borrows them.
175+ containers : RwLock < Table < Arc < dyn Container > > > ,
176+ incoming_values : RwLock < Table < Box < dyn IncomingData > > > ,
177+ outgoing_values : RwLock < Table < host:: OutgoingValue > > ,
178+ object_names : RwLock < Table < Box < dyn ObjectNames > > > ,
183179}
184180
185181impl spin_factors:: SelfInstanceBuilder for InstanceBuilder { }
0 commit comments