@@ -75,13 +75,13 @@ impl Factor for BlobStoreFactor {
75
75
let closure = type_annotate ( move |data| {
76
76
let ( state, table) = get_data_with_table ( data) ;
77
77
BlobStoreDispatch :: new (
78
- state. allowed_containers . clone ( ) ,
79
- state. container_manager . clone ( ) ,
78
+ & state. allowed_containers ,
79
+ state. container_manager . as_ref ( ) ,
80
80
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 ,
85
85
)
86
86
} ) ;
87
87
let linker = ctx. linker ( ) ;
@@ -141,10 +141,10 @@ impl Factor for BlobStoreFactor {
141
141
Ok ( InstanceBuilder {
142
142
container_manager : app_state. container_manager . clone ( ) ,
143
143
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) ) ,
148
148
} )
149
149
}
150
150
}
@@ -170,16 +170,12 @@ pub struct InstanceBuilder {
170
170
///
171
171
/// For the different interfaces to agree on their resource tables, each closure
172
172
/// 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 > > > ,
183
179
}
184
180
185
181
impl spin_factors:: SelfInstanceBuilder for InstanceBuilder { }
0 commit comments