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

Make disposable the classes interacting with native code #16

Open
marcocappolimases opened this issue Mar 30, 2021 · 1 comment
Open
Assignees
Labels
C# Related to C# wrapper code enhancement New feature or request Java Related to Java wrapper code

Comments

@marcocappolimases
Copy link

Is your feature request related to a problem? Please describe.
The management of instance destruction for managed code is now delegated to the garbage collector. This way it is not possible to know what is going on behind the scenes and this can lead to problematic behavior and bugs.

Describe the solution you'd like
Implementing the IDisposable interface in C# and AutoClosable interface in Java for classes related to native code and manage it in native code, to let the developers have more control on what the code really do.

Describe alternatives you've considered
N/A

Additional context
N/A

@mariomastrodicasa mariomastrodicasa added C# Related to C# wrapper code enhancement New feature or request Java Related to Java wrapper code labels Mar 30, 2021
@mariomastrodicasa mariomastrodicasa self-assigned this Mar 30, 2021
@mariomastrodicasa mariomastrodicasa added this to To do in Data Distribution Manager via automation Mar 30, 2021
@mariomastrodicasa
Copy link
Contributor

mariomastrodicasa commented Mar 31, 2021

@marcocappolimases from the point of view of C# (.NET) I think it is another enhancement to use SafeAccessTokenHandle beside to IDisposable pattern to manage the native pointer of C++ interfaces. In Java we use just a long and a different approach to reach underlying layer.

Another improvements to be done is to reference SmartDataDistribution instance within the SmartDataDistributionChannel instance and use the native pointer, or the long in Java, from SmartDataDistribution avoiding the actual copy which is done: actually the copy decouples, in the managed code, the two classes even if they are intimately linked each other. This can prevents the GC to dispose (close) the native pointer related to SmartDataDistribution before every instance of SmartDataDistributionChannel were released.

Another point found during the analysis of the feature: it is missing a method to destroy the native pointer related to SmartDataDistribution. It is important to add a method to the C ++ class DataDistribution like delete (IDataDistribution *) and implements wrappers from C # and Java. The destruction of DataDistribution instance shall be related to the destruction of the subsystem, this implies all channels shall be removed first.

mariomastrodicasa added a commit to mariomastrodicasa/DataDistributionManager that referenced this issue Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# Related to C# wrapper code enhancement New feature or request Java Related to Java wrapper code
Development

No branches or pull requests

2 participants