8000 [breaking] daemon: Fix concurrency and streamline access to PackageManager by cmaglie · Pull Request #1828 · arduino/arduino-cli · GitHub
[go: up one dir, main page]

Skip to content

[breaking] daemon: Fix concurrency and streamline access to PackageManager #1828

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

Merged
merged 17 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

< 8000 fieldset> Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Now GetPackageManager accepts an rpc.InstanceCommand
It has also been deprecated in favor of GetPackageManagerExplorer.
  • Loading branch information
cmaglie committed Aug 23, 2022
commit 316d1d34ec414993f7de3a77ab9d03ab3a5e9503
4 changes: 0 additions & 4 deletions cli/arguments/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ func (p *Port) GetPort(instance *rpc.Instance, sk *sketch.Sketch) (*discovery.Po
}
defer release()

pm := commands.GetPackageManager(instance.Id)
if pm == nil {
return nil, errors.New("invalid instance")
}
dm := pme.DiscoveryManager()
watcher, err := dm.Watch()
if err != nil {
Expand Down
17 changes: 9 additions & 8 deletions commands/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ func (c *coreInstancesContainer) RemoveID(id int32) bool {
return true
}

// GetPackageManager returns a PackageManager for the given ID, or nil if
// ID doesn't exist
func GetPackageManager(id int32) *packagemanager.PackageManager {
i := instances.GetInstance(id)
// GetPackageManager returns a PackageManager. If the package manager is not found
// (because the instance is invalid or has been destroyed), nil is returned.
// Deprecated: use GetPackageManagerExplorer instead.
func GetPackageManager(instance rpc.InstanceCommand) *packagemanager.PackageManager {
i := instances.GetInstance(instance.GetInstance().GetId())
if i == nil {
return nil
}
Expand All @@ -112,12 +113,12 @@ func GetPackageManager(id int32) *packagemanager.PackageManager {
// GetPackageManagerExplorer returns a new package manager Explorer. The
// explorer holds a read lock on the underlying PackageManager and it should
// be released by calling the returned "release" function.
func GetPackageManagerExplorer(instance rpc.InstanceCommand) (explorer *packagemanager.Explorer, release func()) {
i := instances.GetInstance(instance.GetInstance().GetId())
if i == nil {
func GetPackageManagerExplorer(req rpc.InstanceCommand) (explorer *packagemanager.Explorer, release func()) {
pm := GetPackageManager(req)
if pm == nil {
return nil, nil
}
return i.PackageManager.NewExplorer()
return pm.NewExplorer()
}

// GetLibraryManager returns the library manager for the given instance ID
Expand Down
0