-
Notifications
You must be signed in to change notification settings - Fork 29
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
Standalone workspace #476
Standalone workspace #476
Conversation
I didn't know about std::enable_shared_from_this when I started this. It would have been so so so much easier to do it that way. Anyways, what it does is that basically if you create a new instance of a What this means is that we want all instances of propmat_clearsky_agendaExecute(ws, ... // old style
propmat_clearsky_agendaExecute(WorkspaceOmpGuard{ws}, ... // new style where |
…and able to return a shared_ptr of itself
c79c2f6
to
fb78507
Compare
Mainly fixing things related to `Workspace&` now having `shared_ptr()`, so that `Agenda& (const)` can return a `Workspace& (const)` without losing out on the properly co-owning pointer
…s to be owned by a shared pointer now
Fantastic! 👍 |
In short:
Now works as expected.
Features explained:
This makes each new instance of a
Workspace
independent of one-another. The global variables that get defined inworkspace.cc
are used only to initiate the state of a newWorkspace
instance. A newWorkspace
instance knows it is the original by storing a shared pointer to itself. All copies of aWorkspace
are shallow, and they will thus retain a copy of the shared pointer to their original instance.Agenda
instances have a shared pointer to the workspace that created them so that they may outlive the originalWorkspace
. This shared pointer is used to ensure that you cannot copy anAgenda
from oneWorkspace
instance to another, or at least not execute any code properly if this was done.In practice, we only haveWorkspace&
and notstd::shared_ptr<Workspace>&
send in to methods. This means thatAgenda
instances created inside these methods actually get a non-owning shared pointer (std::shared_ptr(&workspace, [](Workspace*){})
). A dud that doesn't delete. This means they can outlive the existence of the originalWorkspace
. The solution seems to me to send instd::shared_ptr<Workspace>&
to all methods. I will attempt this after I make the original draft pull request, but it is a massive overhaul to a lot of Arts files, and I am not sure how python will react.