Bearsampp 2026.7.11
Loading...
Searching...
No Matches
class.action.stopAllServices.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2021-2024 Bearsampp
4 * License: GNU General Public License version 3 or later; see LICENSE.txt
5 * Author: Bear
6 * Website: https://bearsampp.com
7 * Github: https://github.com/Bearsampp
8 */
9
15{
19 private $splash;
20
24 private $processed = false;
25
30
37 public function __construct($args)
38 {
39 global $bearsamppCore, $bearsamppLang, $bearsamppBins, $bearsamppWinbinder;
40
41 // Count enabled services for progress bar
42 $enabledServicesCount = count($bearsamppBins->getServices());
43
44 // Start splash screen
45 $this->splash = new Splash();
46 $this->splash->init(
48 self::GAUGE_PER_SERVICE * $enabledServicesCount + 1,
50 );
51
52 // Set handler for the splash screen window with 1000ms timeout
53 $bearsamppWinbinder->setHandler($this->splash->getWbWindow(), $this, 'processWindow', 1000);
54 $bearsamppWinbinder->mainLoop();
55 $bearsamppWinbinder->reset();
56 }
57
69 public function processWindow($window, $id, $ctrl, $param1, $param2)
70 {
71 global $bearsamppBins, $bearsamppLang, $bearsamppWinbinder;
72
73 // Only process once
74 if ($this->processed) {
75 return;
76 }
77 $this->processed = true;
78
79 // Use parallel shutdown for optimized performance (40-60% faster than sequential)
80 // Falls back to sequential if parallel times out
83 function($current, $total, $serviceName) use ($bearsamppLang) {
84 $this->splash->incrProgressBar();
85 $this->splash->setTextLoading(sprintf($bearsamppLang->getValue(Lang::LOADING_STOP_SERVICE), $serviceName));
86 }
87 );
88
89 // Final update
90 $this->splash->incrProgressBar();
91 $this->splash->setTextLoading($bearsamppLang->getValue(Lang::LOADING_COMPLETE));
92
93 // Close the splash screen and exit cleanly
94 $bearsamppWinbinder->destroyWindow($window);
95 $bearsamppWinbinder->reset();
96 exit(0);
97 }
98}
99
global $bearsamppBins
global $bearsamppLang
global $bearsamppCore
processWindow($window, $id, $ctrl, $param1, $param2)
const LOADING_STOP_SERVICES
const LOADING_COMPLETE
const MENU_STOP_SERVICES
const LOADING_STOP_SERVICE
static stopAllServicesParallel($bearsamppBins, ?callable $progressCallback=null, $shutdownTimeout=15)