-
Notifications
You must be signed in to change notification settings - Fork 592
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
Add CtrlCHandler helper class (Swift) #3469
Conversation
/// @param cb The callback function to invoke when a signal is received. | ||
explicit CtrlCHandler(CtrlCHandlerCallback cb); | ||
|
||
CtrlCHandler(const CtrlCHandler&) = delete; |
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.
Not having these made the class rather bug-prone.
|
||
@interface ICECtrlCHandler () | ||
{ | ||
Ice::CtrlCHandler cppObject; |
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 essential to use a field and not a property here, since a property wants to return a copy of the C++ object (which is not copyable).
Although not tested yet, I believe this helper class can also be used when waiting for either Ctrl+C or a shutdown request, with something like: Task {
await ctrlCHandler.catchSignal()
communicator.shutdown() // initiate shutdown after receiving signal
} and the "main" thread blocks on |
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!
This PR adds the CtrlCHandler helper class to Swift.
It's a thin wrapper over the Ice::CtrlCHandler class provided by Ice C++. It's main consumer is our Swift demos for macOS.