Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[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

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
Apply suggestions from code review
Co-authored-by: per1234 <accounts@perglass.com>
  • Loading branch information
cmaglie and per1234 committed Aug 24, 2022
commit df28c7c66882bef443b7ef8a39a4036fd257bda3
28 changes: 14 additions & 14 deletions 28 arduino/cores/packagemanager/package_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type PackageManager struct {
}

// Builder is used to create a new PackageManager. The builder
// has methods to load patforms and tools to actually build the PackageManager.
// has methods to load platforms and tools to actually build the PackageManager.
// Once the PackageManager is built, it cannot be changed anymore.
type Builder PackageManager

Expand Down Expand Up @@ -82,19 +82,19 @@ func NewBuilder(indexDir, packagesDir, downloadDir, tempDir *paths.Path, userAge

// BuildIntoExistingPackageManager will overwrite the given PackageManager instead
// of building a new one.
func (pmb *Builder) BuildIntoExistingPackageManager(old *PackageManager) {
old.packagesLock.Lock()
defer old.packagesLock.Unlock()
old.log = pmb.log
old.packages = pmb.packages
old.IndexDir = pmb.IndexDir
old.PackagesDir = pmb.PackagesDir
old.DownloadDir = pmb.DownloadDir
old.tempDir = pmb.tempDir
old.packagesCustomGlobalProperties = pmb.packagesCustomGlobalProperties
old.profile = pmb.profile
old.discoveryManager = pmb.discoveryManager
old.userAgent = pmb.userAgent
func (pmb *Builder) BuildIntoExistingPackageManager(target *PackageManager) {
target.packagesLock.Lock()
defer target.packagesLock.Unlock()
target.log = pmb.log
target.packages = pmb.packages
target.IndexDir = pmb.IndexDir
target.PackagesDir = pmb.PackagesDir
target.DownloadDir = pmb.DownloadDir
target.tempDir = pmb.tempDir
target.packagesCustomGlobalProperties = pmb.packagesCustomGlobalProperties
target.profile = pmb.profile
target.discoveryManager = pmb.discoveryManager
target.userAgent = pmb.userAgent
}

// Build builds a new PackageManager.
Expand Down
6 changes: 3 additions & 3 deletions 6 commands/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (c *coreInstancesContainer) GetInstance(id int32) *CoreInstance {
return c.instances[id]
}

// AddAndAssignID saves the CoreInstance and assign an unique ID to
// AddAndAssignID saves the CoreInstance and assigns a unique ID to
// retrieve it later
func (c *coreInstancesContainer) AddAndAssignID(i *CoreInstance) int32 {
c.instancesMux.Lock()
Expand All @@ -86,9 +86,9 @@ func (c *coreInstancesContainer) AddAndAssignID(i *CoreInstance) int32 {
return id
}

// RemoveID removed the CoreInstance referenced by id. Returns true
// RemoveID removes the CoreInstance referenced by id. Returns true
// if the operation is successful, or false if the CoreInstance does
// not exists
// not exist
func (c *coreInstancesContainer) RemoveID(id int32) bool {
c.instancesMux.Lock()
defer c.instancesMux.Unlock()
Expand Down
8 changes: 4 additions & 4 deletions 8 docs/UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func LibraryUpgrade(instanceID int32, libraryNames []string, downloadCB rpc.Down
have been changed to:

```go
func Watch(req *rpc.BoardListWatchRequest) (<-chan *rpc.BoardListWatchResponse, func(), error) { ... ]
func Watch(req *rpc.BoardListWatchRequest) (<-chan *rpc.BoardListWatchResponse, func(), error) { ... }
func LibraryUpgradeAll(req *rpc.LibraryUpgradeAllRequest, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) error { ... }
func LibraryUpgrade(ctx context.Context, req *rpc.LibraryUpgradeRequest, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) error { ... }
```
Expand All @@ -249,12 +249,12 @@ have been changed to:

```go
func GetPackageManager(instance rpc.InstanceCommand) *packagemanager.PackageManager { ... } // Deprecated
func GetPackageManagerExplorer(req rpc.InstanceCommand) (explorer *packagemanager.Explorer, release func()) { ... ]
func GetPackageManagerExplorer(req rpc.InstanceCommand) (explorer *packagemanager.Explorer, release func()) { ... }
func GetLibraryManager(req rpc.InstanceCommand) *librariesmanager.LibrariesManager { ... }
```

Old code using passing the `instanceID` inside the gRPC request must be changed to pass directly the whole gRPC request,
for example:
Old code passing the `instanceID` inside the gRPC request must be changed to pass directly the whole gRPC request, for
example:

```go
eventsChan, closeWatcher, err := board.Watch(req.Instance.Id)
Expand Down
2 changes: 1 addition & 1 deletion 2 rpc/cc/arduino/cli/commands/v1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type DownloadProgressCB func(curr *DownloadProgress)
// TaskProgressCB is a callback to receive progress messages
type TaskProgressCB func(msg *TaskProgress)

// InstanceCommand is an interface thar represents a gRPC command with
// InstanceCommand is an interface that represents a gRPC command with
// a gRPC Instance.
type InstanceCommand interface {
GetInstance() *Instance
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.