Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CtrlCHandler in IceStorm/clock (Swift) #260

Merged
merged 4 commits into from
Feb 5, 2025

Conversation

bernardnormier
Copy link
Member

This PR updates the IceStorm/clock demo to use async/await and the CtrlCHandler.

The focus of this PR is fixing #75. This demo should be reviewed / improved in a follow-up PR.

Fixes #75.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used Greeter as a model. Could we put this slice directory in Sources? I would find it clearer, since the Slice file is a source file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense to me.

} catch {
print("Error: \(error)\n")
return 1
}
}

exit(run())
let ctrlCHandler = Ice.CtrlCHandler()
exit(await run(ctrlCHandler: ctrlCHandler))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not fond of this "exit(run)" pattern, we should replace it.

With this pattern, it's critical to create the CtrlCHandler before the first await call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also unnecessary

do {
try await clock.tick(dateFormatter.string(from: Date()))
} catch let error as Ice.LocalException {
print("tick invocation failed with: \(error.message)")
Copy link
Member Author

@bernardnormier bernardnormier Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plain \(error) for a local exception displays the full C++ stack trace. We should double-check that's the desired behavior.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's undesirable.

Copy link
Member

@externl externl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I agree about the structure, still lots of cleanup to do here.

@bernardnormier bernardnormier merged commit b932dbf into zeroc-ice:main Feb 5, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve termination of Swift servants in response to signals
3 participants