-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/trie-mutex-refactor' into refactor-trie-commit
- Loading branch information
Showing
8 changed files
with
229 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package trie | ||
|
||
import "github.com/multiversx/mx-chain-go/common" | ||
|
||
type disabledGoroutinesManager struct { | ||
err error | ||
} | ||
|
||
// NewDisabledGoroutinesManager creates a new instance of disabledGoroutinesManager | ||
func NewDisabledGoroutinesManager() *disabledGoroutinesManager { | ||
return &disabledGoroutinesManager{} | ||
} | ||
|
||
// ShouldContinueProcessing returns true if there is no error | ||
func (d *disabledGoroutinesManager) ShouldContinueProcessing() bool { | ||
return d.err == nil | ||
} | ||
|
||
// CanStartGoRoutine returns false | ||
func (d *disabledGoroutinesManager) CanStartGoRoutine() bool { | ||
return false | ||
} | ||
|
||
// EndGoRoutineProcessing does nothing | ||
func (d *disabledGoroutinesManager) EndGoRoutineProcessing() { | ||
} | ||
|
||
// SetNewErrorChannel does nothing | ||
func (d *disabledGoroutinesManager) SetNewErrorChannel(_ common.BufferedErrChan) error { | ||
return nil | ||
} | ||
|
||
// SetError sets the given error | ||
func (d *disabledGoroutinesManager) SetError(err error) { | ||
d.err = err | ||
} | ||
|
||
// GetError returns the error | ||
func (d *disabledGoroutinesManager) GetError() error { | ||
return d.err | ||
} | ||
|
||
// IsInterfaceNil returns true if there is no value under the interface | ||
func (d *disabledGoroutinesManager) IsInterfaceNil() bool { | ||
return d == nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package trie | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/multiversx/mx-chain-core-go/core/check" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNewDisabledGoroutinesManager(t *testing.T) { | ||
t.Parallel() | ||
|
||
d := NewDisabledGoroutinesManager() | ||
assert.False(t, check.IfNil(d)) | ||
} | ||
|
||
func TestDisabledGoroutinesManager_ShouldContinueProcessing(t *testing.T) { | ||
t.Parallel() | ||
|
||
d := NewDisabledGoroutinesManager() | ||
assert.True(t, d.ShouldContinueProcessing()) | ||
|
||
d.SetError(errors.New("error")) | ||
assert.False(t, d.ShouldContinueProcessing()) | ||
} | ||
|
||
func TestDisabledGoroutinesManager_CanStartGoRoutine(t *testing.T) { | ||
t.Parallel() | ||
|
||
d := NewDisabledGoroutinesManager() | ||
assert.False(t, d.CanStartGoRoutine()) | ||
} | ||
|
||
func TestDisabledGoroutinesManager_SetAndGetError(t *testing.T) { | ||
t.Parallel() | ||
|
||
d := NewDisabledGoroutinesManager() | ||
assert.Nil(t, d.GetError()) | ||
|
||
err := errors.New("error") | ||
d.SetError(err) | ||
assert.Equal(t, err, d.GetError()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters