MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / new_inner

Method new_inner

crates/core/src/host/module_host.rs:1334–1359  ·  view source on GitHub ↗
(
        module: M,
        init_inst: Option<M::Instance>,
        metrics: InstanceManagerMetrics,
        max_instances: Option<NonZeroUsize>,
    )

Source from the content-addressed store, hash-verified

1332 }
1333
1334 fn new_inner(
1335 module: M,
1336 init_inst: Option<M::Instance>,
1337 metrics: InstanceManagerMetrics,
1338 max_instances: Option<NonZeroUsize>,
1339 ) -> Self {
1340 let mut instances = VecDeque::new();
1341 instances.extend(init_inst);
1342 let initial_instances = instances.len();
1343 if let Some(max_instances) = max_instances {
1344 assert!(
1345 initial_instances <= max_instances.get(),
1346 "initial module instance count exceeds bounded pool size"
1347 );
1348 }
1349 for _ in 0..instances.len() {
1350 metrics.track_initial_instance();
1351 }
1352
1353 Self {
1354 instances: Mutex::new(instances),
1355 module,
1356 metrics,
1357 instance_slots: max_instances.map(|max_instances| Arc::new(Semaphore::new(max_instances.get()))),
1358 }
1359 }
1360
1361 async fn with_instance<R>(&self, f: impl AsyncFnOnce(M::Instance) -> (R, M::Instance)) -> R {
1362 let ModuleInstanceLease { instance, slot } = self.get_instance().await;

Callers

nothing calls this directly

Calls 6

newFunction · 0.50
extendMethod · 0.45
lenMethod · 0.45
mapMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected