]> git.mxchange.org Git - hub.git/commitdiff
The chunk handler instance of the assember class is now set for avoiding expensive...
authorRoland Haeder <roland@mxchange.org>
Sat, 15 Feb 2014 23:56:05 +0000 (00:56 +0100)
committerRoland Haeder <roland@mxchange.org>
Sat, 15 Feb 2014 23:56:05 +0000 (00:56 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/main/package/assembler/class_PackageAssembler.php
application/hub/main/package/class_NetworkPackage.php

index 48b98f35a8e0f5b5884f697aaa94528d9825f75d..e991f28d1eca93670014cbd4e18173bd3dcf019c 100644 (file)
@@ -62,6 +62,12 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable
                // And set it
                $assemblerInstance->setInputStreamInstance($streamInstance);
 
+               // Now get a chunk handler instance
+               $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance();
+
+               // Set handler instance
+               $assemblerInstance->setHandlerInstance($handlerInstance);
+
                // Return the prepared instance
                return $assemblerInstance;
        }
@@ -145,7 +151,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable
         */
        private function handlePackageByUnhandledPackage (array $packageContent) {
                // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: packageData[' . BaseRawDataHandler::PACKAGE_RAW_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]);
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: packageData[' . BaseRawDataHandler::PACKAGE_RAW_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]);
 
                // Check for some conditions
                if ((!$this->ifInputBufferIsEmpty()) || (!$this->isPackageContentCompleted($packageContent))) {
@@ -181,7 +187,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable
         */
        public function handlePendingData () {
                // Debug output
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData);
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData);
 
                // Assert on condition
                assert(!$this->isPendingDataEmpty());
@@ -196,7 +202,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable
                $this->pendingData = '';
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.');
 
                // Make sure last CHUNK_SEPARATOR is not there
                if (substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
@@ -211,11 +217,9 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable
                 */
                $chunks = explode(PackageFragmenter::CHUNK_SEPARATOR, $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]);
 
-               // Now get a chunk handler instance
-               $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance();
-
                // Add all chunks because the last final chunk is found
-               $handlerInstance->addAllChunksWithFinal($chunks);
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Going to add ' . count($chunks) . ' to chunk handler ...');
+               $this->getHandlerInstance()->addAllChunksWithFinal($chunks);
        }
 }
 
index 66d60be4105730c0c9e9d1a483dc0e783bee5a9a..dbbbf98ab7f199d9801abaeaf9baecd709fe272d 100644 (file)
@@ -870,7 +870,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                $decodedData = $handlerInstance->getNextRawData();
 
                // Very noisy debug message:
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, TRUE));
 
                // And push it on our stack
                $this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECODED_INCOMING, $decodedData);