-
Notifications
You must be signed in to change notification settings - Fork 215
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
Conversation
swift/IceStorm/clock/slice/Clock.ice
Outdated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
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.