|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00026 require_once 'Zend/Service/WindowsAzure/RetryPolicy/RetryPolicyAbstract.php'; 00027 00031 require_once 'Zend/Service/WindowsAzure/RetryPolicy/Exception.php'; 00032 00040 class Zend_Service_WindowsAzure_RetryPolicy_RetryN extends Zend_Service_WindowsAzure_RetryPolicy_RetryPolicyAbstract 00041 { 00047 protected $_retryCount = 1; 00048 00054 protected $_retryInterval = 0; 00055 00062 public function __construct($count = 1, $intervalBetweenRetries = 0) 00063 { 00064 $this->_retryCount = $count; 00065 $this->_retryInterval = $intervalBetweenRetries; 00066 } 00067 00075 public function execute($function, $parameters = array()) 00076 { 00077 $returnValue = null; 00078 00079 for ($retriesLeft = $this->_retryCount; $retriesLeft >= 0; --$retriesLeft) { 00080 try { 00081 $returnValue = call_user_func_array($function, $parameters); 00082 return $returnValue; 00083 } catch (Exception $ex) { 00084 if ($retriesLeft == 1) { 00085 throw new Zend_Service_WindowsAzure_RetryPolicy_Exception("Exceeded retry count of " . $this->_retryCount . ". " . $ex->getMessage()); 00086 } 00087 00088 usleep($this->_retryInterval * 1000); 00089 } 00090 } 00091 } 00092 }