mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-22 15:10:13 +00:00
Feature: Faster start & stop times (#648)
* Updates starting and stopping routines to be a bit more parallel with less waiting required * Removes stop, removes debugging output * linting and test fixes * Add extra kill switch for exiting on exchange loading delay * Fixes fun math * breaks loop instead of switch. Moves param warns higher * Removes unceccary gos. passes in cfg to remove data race * Removes os signal processing. Fixes bad master merge
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/thrasher-corp/gocryptotrader/engine/subsystem"
|
||||
"github.com/thrasher-corp/gocryptotrader/log"
|
||||
)
|
||||
|
||||
@@ -79,7 +80,7 @@ func SpawnWorker() error {
|
||||
// configuration, then spawns workers
|
||||
func (d *Dispatcher) start(workers, channelCapacity int) error {
|
||||
if atomic.LoadUint32(&d.running) == 1 {
|
||||
return errors.New(errAlreadyStarted)
|
||||
return fmt.Errorf("dispatcher %w", subsystem.ErrSubSystemAlreadyStarted)
|
||||
}
|
||||
|
||||
if workers < 1 {
|
||||
@@ -114,7 +115,7 @@ func (d *Dispatcher) start(workers, channelCapacity int) error {
|
||||
// stop stops the service and shuts down all worker routines
|
||||
func (d *Dispatcher) stop() error {
|
||||
if !atomic.CompareAndSwapUint32(&d.running, 1, 0) {
|
||||
return errors.New(errCannotShutdown)
|
||||
return fmt.Errorf("dispatcher %w", subsystem.ErrSubSystemNotStarted)
|
||||
}
|
||||
close(d.shutdown)
|
||||
ch := make(chan struct{})
|
||||
@@ -176,7 +177,7 @@ func (d *Dispatcher) spawnWorker() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Relayer routine relays communications across the defined routes
|
||||
// relayer routine relays communications across the defined routes
|
||||
func (d *Dispatcher) relayer(i *sync.WaitGroup) {
|
||||
atomic.AddInt32(&d.count, 1)
|
||||
d.wg.Add(1)
|
||||
|
||||
@@ -19,8 +19,6 @@ const (
|
||||
DefaultHandshakeTimeout = 200 * time.Nanosecond
|
||||
|
||||
errNotInitialised = "dispatcher not initialised"
|
||||
errAlreadyStarted = "dispatcher already started"
|
||||
errCannotShutdown = "dispatcher cannot shutdown, already stopped"
|
||||
errShutdownRoutines = "dispatcher did not shutdown properly, routines failed to close"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user