1
0
mirror of https://github.com/ManyakRus/starter.git synced 2025-11-25 23:02:22 +02:00

сделал EnableAfterDuration{}

This commit is contained in:
Nikitin Aleksandr
2025-02-12 17:48:53 +03:00
parent 65dcfcd3c6
commit 11c622801b
2 changed files with 50 additions and 43 deletions

View File

@@ -8,7 +8,6 @@ import (
"encoding/gob"
"errors"
"fmt"
"github.com/ManyakRus/starter/stopapp"
"github.com/google/uuid"
"golang.org/x/exp/constraints"
"google.golang.org/protobuf/types/known/timestamppb"
@@ -32,16 +31,6 @@ import (
//var log = logger.GetLog()
// IEnable - интерфейс для включения
type IEnable interface {
Enable()
}
// IDisable - интерфейс для отключения
type IDisable interface {
Disable()
}
// IsTestApp - возвращает true если это тестовая среда выполнения приложения
func IsTestApp() bool {
Otvet := true
@@ -1499,35 +1488,3 @@ func StringFromBool(value bool) string {
// *d = Time(t)
// return nil
//}
// EnableAfterDuration - выполняет Enable() после паузы
func EnableAfterDuration(Object IEnable, Duration time.Duration) {
if Object == nil {
return
}
stopapp.GetWaitGroup_Main().Add(1)
go EnableAfterDuration_go(Object, Duration)
}
// EnableAfterMilliSeconds - выполняет Enable() после паузы
func EnableAfterMilliSeconds(Object IEnable, MilliSeconds int) {
if Object == nil {
return
}
stopapp.GetWaitGroup_Main().Add(1)
go EnableAfterDuration_go(Object, time.Duration(MilliSeconds)*time.Millisecond)
}
// EnableAfterDuration_go - горутина, выполняет Enable() после паузы
func EnableAfterDuration_go(Object IEnable, Duration time.Duration) {
defer stopapp.GetWaitGroup_Main().Done()
if Object == nil {
return
}
//
time.Sleep(Duration)
Object.Enable()
}