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

Simplify loading API. #145

Closed
wants to merge 1 commit into from
Closed

Conversation

reitermarkus
Copy link

As I understand from KyleMayes/clang-rs#26, the library should only be loaded once per thread.

This changes the load method so it returns an Rc<SharedLibrary>, since you cannot share the library across threads anyways.

This also removes the get/set_library function, which previously claimed they allow sharing the library across threads, which should not be possible.

The unload method returns an error if the current thread still references the library.

@KyleMayes
Copy link
Owner

Are these changes (and the related ones in clang-sys) driven by a particular need?
Or is it just cleaning up the API and making it harder to misuse (e.g., sharing a libclang instance between threads?
I ask because this would be a breaking change and I don't want to release a v2 of this crate unless I had a really good reason.

@reitermarkus
Copy link
Author

reitermarkus commented Sep 23, 2022

The need is for running multiple tests in parallel.

Currently, clang::Clang::new just fails when called a second time.

@reitermarkus
Copy link
Author

@KyleMayes, can you have another look here?

@KyleMayes
Copy link
Owner

KyleMayes commented Oct 21, 2022 via email

@KyleMayes
Copy link
Owner

Took another look, I'm very hesitant to merge this because it is a breaking change.

I can see two alternatives:

  1. Put this new loading API behind a Cargo feature
  2. Just keep the current loading API, which is my preference

I understand that the current loading API is more easily misused, but I don't think it's worth the breaking change.

Your desire to have the ability to have multiple Clang instances in clang-rs should still be possible with the current loading API, correct?

@reitermarkus
Copy link
Author

I'm very hesitant to merge this because it is a breaking change.

I don't agree that a breaking change is inherently a reason not to merge this, sometimes breaking stuff in inevitable when improving stuff. That is of course not to say these changes cannot be improved further before releasing this in a new version.

Your desire to have the ability to have multiple Clang instances in clang-rs should still be possible with the current loading API, correct?

I guess it is possible, but this was the cleanest solution I could come up with. I will try to have another look at the clang-rs side of things.

@KyleMayes
Copy link
Owner

I'm not inherently opposed to breaking changes, it's just that by the nature of this crate and how it is used, non-backwards-compatible versions cause problems in the ecosystem. I know there's stuff like the semver trick but that sounds like it would require significantly more effort than I am willing to put in.

@reitermarkus
Copy link
Author

Ah, I see. I didn't think about the types becoming incompatible.

@KyleMayes KyleMayes closed this May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants