]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Worker.php
Replace Lock::acquire() with DI::lock()->acquire()
[friendica.git] / src / Core / Worker.php
index 62f7bd4c6ac7609d12bcc84bb11eb28702897e11..ed0f3a2e782c84e6fb5c8bfece784087807db087 100644 (file)
@@ -48,8 +48,6 @@ class Worker
         */
        public static function processQueue($run_cron = true)
        {
-               $a = \get_app();
-
                // Ensure that all "strtotime" operations do run timezone independent
                date_default_timezone_set('UTC');
 
@@ -117,7 +115,7 @@ class Worker
                                }
 
                                // Trying to fetch new processes - but only once when successful
-                               if (!$refetched && Lock::acquire('worker_process', 0)) {
+                               if (!$refetched && DI::lock()->acquire('worker_process', 0)) {
                                        self::findWorkerProcesses();
                                        Lock::release('worker_process');
                                        self::$state = self::STATE_REFETCH;
@@ -131,7 +129,7 @@ class Worker
                        if (!self::getWaitingJobForPID()) {
                                self::$state = self::STATE_LONG_LOOP;
 
-                               if (Lock::acquire('worker', 0)) {
+                               if (DI::lock()->acquire('worker', 0)) {
                                // Count active workers and compare them with a maximum value that depends on the load
                                        if (self::tooMuchWorkers()) {
                                                Logger::log('Active worker limit reached, quitting.', Logger::DEBUG);
@@ -372,7 +370,7 @@ class Worker
         */
        private static function execFunction($queue, $funcname, $argv, $method_call)
        {
-               $a = \get_app();
+               $a = DI::app();
 
                $argc = count($argv);
 
@@ -935,7 +933,7 @@ class Worker
                }
 
                $stamp = (float)microtime(true);
-               if (!Lock::acquire('worker_process')) {
+               if (!DI::lock()->acquire('worker_process')) {
                        return false;
                }
                self::$lock_duration += (microtime(true) - $stamp);
@@ -979,7 +977,7 @@ class Worker
                        return;
                }
 
-               $url = System::baseUrl()."/worker";
+               $url = DI::baseUrl() . '/worker';
                Network::fetchUrl($url, false, 1);
        }
 
@@ -1083,7 +1081,7 @@ class Worker
 
                $args = ['no_cron' => !$do_cron];
 
-               $a = get_app();
+               $a = DI::app();
                $process = new Core\Process(DI::logger(), DI::mode(), DI::config(), $a->getBasePath());
                $process->run($command, $args);
 
@@ -1174,7 +1172,7 @@ class Worker
                }
 
                // If there is a lock then we don't have to check for too much worker
-               if (!Lock::acquire('worker', 0)) {
+               if (!DI::lock()->acquire('worker', 0)) {
                        return $added;
                }