MCPcopy Index your code
hub / github.com/NativeScript/SimDeck / discover_targets

Function discover_targets

packages/server/src/webkit.rs:102–129  ·  view source on GitHub ↗
(
    udid: &str,
    http_origin: Option<&str>,
)

Source from the content-addressed store, hash-verified

100}
101
102pub async fn discover_targets(
103 udid: &str,
104 http_origin: Option<&str>,
105) -> Result<WebKitTargetDiscovery, AppError> {
106 let monitor = webkit_discovery_monitor(udid);
107 monitor.clone().ensure_started();
108
109 let deadline = Instant::now() + WEBKIT_DISCOVERY_TIMEOUT;
110 loop {
111 let discovery = monitor.discovery(http_origin).await;
112 if !discovery.targets.is_empty() || Instant::now() >= deadline {
113 return Ok(discovery);
114 }
115
116 let Some(remaining) = deadline.checked_duration_since(Instant::now()) else {
117 return Ok(discovery);
118 };
119 if timeout(
120 remaining.min(Duration::from_millis(250)),
121 monitor.notify.notified(),
122 )
123 .await
124 .is_err()
125 {
126 continue;
127 }
128 }
129}
130
131fn webkit_discovery_monitor(udid: &str) -> Arc<WebKitDiscoveryMonitor> {
132 let monitors = WEBKIT_DISCOVERY_MONITORS.get_or_init(|| Mutex::new(HashMap::new()));

Callers

nothing calls this directly

Calls 5

webkit_discovery_monitorFunction · 0.85
discoveryMethod · 0.80
is_emptyMethod · 0.80
cloneMethod · 0.65
ensure_startedMethod · 0.45

Tested by

no test coverage detected