Communicator Initialization and Destruction
Creating a Communicator
You create a communicator by calling Ice.initialize, for example:
let communicator = try Ice.initialize(CommandLine.arguments)
initialize scans the argument array for any command-line options that are relevant to the Ice runtime. If anything goes wrong during initialization, initialize throws an exception.
The initialize shown above does not modify the argument array. You can use another overload of initialize that removes all Ice-related options from the argument array.
Once you no longer need a Communicator, you must call destroy on this Communicator. The destroy method is responsible for cleaning up the communicator. In particular, in an Ice server, destroy waits for operation implementations that are still executing to complete. In addition, destroy ensures that any outstanding threads are joined with and reclaims a number of operating system resources, such as file descriptors and memory. Never allow your application to terminate without calling destroy first.
The general shape of a simple command-line Swift application becomes:
let communicator = try Ice.initialize(CommandLine.arguments)
defer {
communicator.destroy()
}
Initialization Data
When a communicator is created, its constructor or the initialize method configures several features that control its behavior. Once set, these features remain in effect for the lifetime of the communicator and cannot be changed afterward. Therefore, any customization of these features must be done at communicator creation time.
The InitializationData class or struct holds all the features (or options) that you can customize when you create a communicator.