Home About Notes

Ping 1.0.3

Jun 27, 2024

A small update that fixed some big bugs.

With all the swift 6 concurrency things I have been looking at lately I decided to turn it on for this project and as it turns out it helped solve the issues. 

There were two bugs. One, sometimes when you opened the app it would freeze. Two, when entering in a new URL to monitor it would not add it to the list and it would freeze and crash. 

The main problem was that I was trying to be cleaver and group update logic together, but it wasn't executing the tasks correctly and would not return to the main thread to update, or it would do all the work on the main thread and lock up the UI. 

This in conjunction with swift data and not understanding some of the implications of passing objects between boundaries and model context lead to quite a buggy app.

But i'm please to announce that 1.0.3 should solve these issues. 

Using swift async await properly can lead to some nice code:

.task {
    for server in servers {
        Task {
            ...
            let response = await Network.shared.service.ping(url)
            ...
        }
    }
}

await withTaskGroup(of: (Server, ServerResponse).self) { group in
    ...
    group.addTask {
        let response = await Network.shared.service.ping(url)
        ...
    }
    for await (server, response) in group {
        ...
    }
}

available for immediate download