Skip to content

Commit

Permalink
technical debt
Browse files Browse the repository at this point in the history
  • Loading branch information
e154 committed Jan 25, 2024
1 parent dff5106 commit 4cf120c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
6 changes: 2 additions & 4 deletions plugins/alexa/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ func NewServer(adaptors *adaptors.Adaptors,
// Start ...
func (s *Server) Start() {

if s.isStarted.Load() {
if !s.isStarted.CompareAndSwap(false, true) {
return
}
s.isStarted.Store(true)

s.init()

Expand Down Expand Up @@ -119,10 +118,9 @@ func (s *Server) init() {

// Stop ...
func (s *Server) Stop() {
if !s.isStarted.Load() {
if !s.isStarted.CompareAndSwap(true, false) {
return
}
s.isStarted.Store(false)

//todo fix
//s.gate.SetAlexaApiEngine(nil)
Expand Down
13 changes: 5 additions & 8 deletions system/supervisor/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,20 @@ func NewPlugin() *Plugin {

// Load ...
func (p *Plugin) Load(ctx context.Context, service Service, actorConstructor ActorConstructor) error {
p.Service = service
p.actorConstructor = actorConstructor

if p.IsStarted.Load() {
if !p.IsStarted.CompareAndSwap(false, true) {
return apperr.ErrPluginIsLoaded
}
p.IsStarted.Store(true)

p.Service = service
p.actorConstructor = actorConstructor

return nil
}

// Unload ...
func (p *Plugin) Unload(ctx context.Context) error {

if !p.IsStarted.Load() {
if !p.IsStarted.CompareAndSwap(true, false) {
return apperr.ErrPluginIsUnloaded
}

Expand All @@ -80,8 +79,6 @@ func (p *Plugin) Unload(ctx context.Context) error {
return true
})

p.IsStarted.Store(false)

return nil
}

Expand Down

0 comments on commit 4cf120c

Please sign in to comment.