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

Minor clean-up in the plugin infrastructure. #4895

Merged
merged 1 commit into from
Jul 15, 2022

Conversation

bangerth
Copy link
Contributor

@bangerth bangerth commented Jul 9, 2022

A companion to #4891.

/rebuild

@@ -301,8 +301,7 @@ namespace aspect
// if any plugins have been registered, then delete
// the list
if (plugins != nullptr)
delete plugins;
plugins = nullptr;
plugins.reset();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove the if here and unconditionally call .reset()?

@bangerth
Copy link
Contributor Author

So done.

@tjhei
Copy link
Member

tjhei commented Jul 12, 2022

There is also a compile error. 😉

@@ -181,7 +181,7 @@ namespace aspect
* need not worry whether we try to add something to this list before
* the lists's constructor has successfully run
*/
static std::list<PluginInfo> *plugins;
static std::unique_ptr<std::list<PluginInfo>> plugins;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the comment above still apply regarding initialization order? unique_ptr does have a constructor.

@bangerth
Copy link
Contributor Author

Oh, I had totally forgotten about the reason why we used pointers. Thanks for digging this out of the comments!

This invalidates the whole idea and probably explains why the original idea resulted in all sorts of segfaults on the testers (though interestingly not on my laptop). I've stripped the patch back to the minimal pieces that keep things as a pointer.

@tjhei
Copy link
Member

tjhei commented Jul 13, 2022

Didn't have to do much digging, it was right there above the declaration. I actually looked because I was wondering why we have a pointer instead of a std::list directly.

Another way to work around the awkward pointer would be to have a getter that returns a reference to a static std::list.

description,
declare_parameters_function,
factory_function));
plugins->emplace_back (PluginInfo(name,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
plugins->emplace_back (PluginInfo(name,
plugins->emplace_back (name,

Otherwise emplace_back will do the same as push_back.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good eye! So fixed!

@tjhei
Copy link
Member

tjhei commented Jul 13, 2022

I was lazy and only suggested the opening paren and not both. :-)

/home/runner/work/aspect/aspect/include/aspect/plugins.h:337:49:error: expected ‘;’ before ‘)’ token

@bangerth
Copy link
Contributor Author

Ah, good grief. That's what happens when you work on your laptop and are working on the one file that is literally included into every single .h file and for which compiling is going to fry your knees. Not even simulator.h is that bad...

@tjhei
Copy link
Member

tjhei commented Jul 14, 2022

I think ASPECT is s pleasure to develop because of the fast compilation times. Always annoyed when I have to recompile deal.II...
Are you using unity and precompiled headers?

@bangerth
Copy link
Contributor Author

Neither on my laptop. But there really also isn't all that much you can do when you're mucking around with the most central pieces. You're entirely right when working on plugins or individual .cc files -- they are not very connected and pleasantly fast to compile.

(Why not unity: Because not using unity is fastest when you're working on a single .cc file. I don't know what impact PCH would have.)

@tjhei
Copy link
Member

tjhei commented Jul 15, 2022

Try both some day. Recompiling one of the unity files when a single .cc changes is also surprisingly fast.

@tjhei tjhei merged commit df19323 into geodynamics:main Jul 15, 2022
@bangerth bangerth deleted the unique_ptr-2 branch July 15, 2022 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants