Compare commits

...

1 Commits

Author SHA1 Message Date
chen08209
9f89fe8b29 Optimize repeat healthcheck 2024-05-06 17:17:26 +08:00
8 changed files with 26 additions and 8 deletions

View File

@@ -175,8 +175,10 @@ func patchConfig(general *config.General) {
const concurrentCount = math.MaxInt
var wg = sync.WaitGroup{}
var exit = make(chan struct{})
func hcCompatibleProvider(proxyProviders map[string]provider.ProxyProvider) {
wg := sync.WaitGroup{}
ch := make(chan struct{}, concurrentCount)
for _, proxyProvider := range proxyProviders {
proxyProvider := proxyProvider
@@ -184,6 +186,11 @@ func hcCompatibleProvider(proxyProviders map[string]provider.ProxyProvider) {
log.Infoln("Start initial Compatible provider %s", proxyProvider.Name())
wg.Add(1)
ch <- struct{}{}
select {
case <-exit:
return // 收到退出信号,退出协程
default:
}
go func() {
defer func() { <-ch; wg.Done() }()
if err := proxyProvider.Initial(); err != nil {
@@ -193,7 +200,13 @@ func hcCompatibleProvider(proxyProviders map[string]provider.ProxyProvider) {
}
}
}
func cancelHc() {
close(exit)
wg.Wait()
exit = make(chan struct{})
wg = sync.WaitGroup{}
}
func applyConfig(isPatch bool) {
@@ -205,5 +218,6 @@ func applyConfig(isPatch bool) {
patchConfig(cfg.General)
} else {
executor.ApplyConfig(cfg, true)
healthcheck()
}
}

View File

@@ -120,6 +120,10 @@ func changeProxy(s *C.char) bool {
return true
}
// clearEffect
func clearConfigEffect() {
}
//export getTraffic
func getTraffic() *C.char {
up, down := statistic.DefaultManager.Now()

View File

@@ -236,7 +236,6 @@ class AppController {
}
healthcheck() {
if (globalState.healthcheckLock) return;
for (final delay in appState.delayMap.entries) {
setDelay(
Delay(

View File

@@ -84,7 +84,11 @@ class _ProxiesFragmentState extends State<ProxiesFragment>
);
},
builder: (_, state, __) {
_tabController ??= TabController(
if (_tabController != null) {
_tabController!.dispose();
_tabController = null;
}
_tabController = TabController(
length: state.groupNames.length,
vsync: this,
initialIndex: state.currentIndex,

View File

@@ -23,7 +23,6 @@ class GlobalState {
List<Function> updateFunctionLists = [];
List<NavigationItem> currentNavigationItems = [];
bool updatePackagesLock = false;
bool healthcheckLock = false;
startListenUpdate() {
if (timer != null && timer!.isActive == true) return;

View File

@@ -38,14 +38,12 @@ class _ClashMessageContainerState extends State<ClashMessageContainer>
@override
void onDelay(Delay delay) {
globalState.healthcheckLock = true;
context.appController.setDelay(delay);
WidgetsBinding.instance.addPostFrameCallback((_) {
globalState.updateSortNumDebounce ??= debounce<Function()>(
() {
context.appController.updateGroups();
context.appController.appState.sortNum++;
globalState.healthcheckLock = false;
},
milliseconds: 5000,
);

View File

@@ -1,7 +1,7 @@
name: fl_clash
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
publish_to: 'none'
version: 0.7.11
version: 0.7.12
environment:
sdk: '>=3.1.0 <4.0.0'