Skip to main content
Glama
TimeoutHelper.swift824 B
import Foundation struct TimeoutHelper { private init() {} static func repeatUntil(timeout: TimeInterval, delta: TimeInterval, block: () -> Bool) async throws { guard delta >= 0 else { throw NSError(domain: "Invalid value", code: 1, userInfo: [NSLocalizedDescriptionKey: "Delta cannot be negative"]) } let timeout = Date().addingTimeInterval(timeout) while Date() < timeout { do { try await Task.sleep(nanoseconds: UInt64(1_000_000_000 * delta)) } catch { throw NSError(domain: "Failed to sleep task", code: 2, userInfo: [NSLocalizedDescriptionKey: "Task could not be put to sleep"]) } if (block()) { break } } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mobile-dev-inc/Maestro'

If you have feedback or need assistance with the MCP directory API, please join our Discord server