Clean-Up

Design programs to behave appropriately when they exit, and when they create a new realm object and its associated objects. (For example, creating new realm objects could be a recovery path after the FTL server disables the client process.)

Proper clean-up serves two goals:

  • The FTL server and administrators can distinguish application processes that exit cleanly from processes that exit abnormally. When a process cleans up, you can infer that it exited deliberately, rather than unexpectedly.
  • Clean-up manages the resources within a process that closes and reopens the realm but does not exit.

Program Exit

When a program exits, it is important to close the realm object. This step closes the FTL server’s connection to the program process. The FTL server stops monitoring the process.

When a program exits, it is not necessary to close or destroy other objects associated with the realm object.

Nonetheless, in C programs, you must close the top-level FTL object as well as the realm object.

Close and Reopen the Realm

In contrast, the clean-up requirements are different when a program does not completely exit, but instead creates a new realm object. In this situation, programs must do these steps, in order:

Close or destroy objects associated with the defunct realm object: including messages, property objects, field reference objects, content matchers, subscribers, publishers, inboxes, and event queues.

Close the defunct realm object.

Open a new realm object (that is, connect to the FTL server).

Create objects associated with the new realm.