stanley-king %!s(int64=3) %!d(string=hai) anos
pai
achega
aa8a8c097e
Modificáronse 1 ficheiros con 13 adicións e 20 borrados
  1. 13 20
      core/framework/libraries/CoRefPool.php

+ 13 - 20
core/framework/libraries/CoRefPool.php

@@ -25,9 +25,7 @@ abstract class CoRefPool
         }
 
         if(!empty($this->mFreeClients)) {
-            $client = $this->mFreeClients[0];
-            unset($this->mFreeClients[0]);
-            $this->mFreeClients = array_values($this->mFreeClients);
+            $client = array_shift($this->mFreeClients);
             $this->mUsingClients[$cid] = ['client' => $client, 'ref_count' => 1,'ifTransacting' => false];
         }
         elseif(count($this->mUsingClients) < $this->mMaxClient) {
@@ -37,14 +35,12 @@ abstract class CoRefPool
         else {
             $this->mSuspendCIDS[] = Co::getCid();
             Co::suspend();
-            $client = $this->mFreeClients[0];
-            unset($this->mFreeClients[0]);
-            $this->mFreeClients = array_values($this->mFreeClients);
+            $client = array_shift($this->mFreeClients);
             $this->mUsingClients[$cid] = ['client' => $client, 'ref_count' => 1,'ifTransacting' => false];
         }
 
-        $count = count($this->mUsingClients);
-        Log::record("mysqli get cid={$cid} mUsingCount={$count}",Log::DEBUG);
+//        $count = count($this->mUsingClients);
+//        Log::record("mysqli get cid={$cid} mUsingCount={$count}",Log::DEBUG);
 
         return $client;
     }
@@ -85,7 +81,7 @@ abstract class CoRefPool
     public function begin($cid)
     {
         if(array_key_exists($cid,$this->mUsingClients)) {
-            return $this->mUsingClients[$cid]['ifTransacting'] = true;
+            $this->mUsingClients[$cid]['ifTransacting'] = true;
         } else {
             $msg = __METHOD__ . " mysqli cannot find mysqli cid={$cid} client";
             Log::record($msg,Log::DEBUG);
@@ -96,7 +92,7 @@ abstract class CoRefPool
     public function commit($cid)
     {
         if(array_key_exists($cid,$this->mUsingClients)) {
-            return $this->mUsingClients[$cid]['ifTransacting'] = false;
+            $this->mUsingClients[$cid]['ifTransacting'] = false;
         } else {
             $msg = __METHOD__ . " mysqli cannot find mysqli cid={$cid} client";
             Log::record($msg,Log::DEBUG);
@@ -107,7 +103,7 @@ abstract class CoRefPool
     public function rollback($cid)
     {
         if(array_key_exists($cid,$this->mUsingClients)) {
-            return $this->mUsingClients[$cid]['ifTransacting'] = false;
+            $this->mUsingClients[$cid]['ifTransacting'] = false;
         } else {
             $msg = __METHOD__ . " mysqli cannot find mysqli cid={$cid} client";
             Log::record($msg,Log::DEBUG);
@@ -117,7 +113,7 @@ abstract class CoRefPool
 
     public function put($cid)
     {
-        Log::record("CoRefPool put cid={$cid}",Log::DEBUG);
+//        Log::record("CoRefPool put cid={$cid}",Log::DEBUG);
         if(array_key_exists($cid,$this->mUsingClients))
         {
             $this->mUsingClients[$cid]['ref_count'] -= 1;
@@ -133,12 +129,11 @@ abstract class CoRefPool
                 if($suspend_cid > 0) {
                     Co::resume($suspend_cid);
                 }
-
-                Log::record("mysqli CoRefPool put cid={$cid} suspend_cid={$suspend_cid} refcount={$refcount}",Log::DEBUG);
-            }
-            else {
-                Log::record("mysqli CoRefPool put cid={$cid} refcount={$refcount}",Log::DEBUG);
+//                Log::record("mysqli CoRefPool put cid={$cid} suspend_cid={$suspend_cid} refcount={$refcount}",Log::DEBUG);
             }
+//            else {
+//                Log::record("mysqli CoRefPool put cid={$cid} refcount={$refcount}",Log::DEBUG);
+//            }
         }
         else {
             $msg = __METHOD__ . " mysqli cannot find mysqli cid={$cid} client";
@@ -152,9 +147,7 @@ abstract class CoRefPool
         if (empty($this->mSuspendCIDS)) {
             return 0;
         } else {
-            $cid = $this->mSuspendCIDS[0];
-            unset($this->mSuspendCIDS[0]);
-            $this->mSuspendCIDS = array_values($this->mSuspendCIDS);
+            $cid = array_shift($this->mSuspendCIDS);
             return $cid;
         }
     }