Changeset 12443
- Timestamp:
- 02/14/08 11:32:03 (11 months ago)
- Files:
-
- 1 modified
-
util/branches/dev/jsdoc/jsdoc.module (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
util/branches/dev/jsdoc/jsdoc.module
r12442 r12443 390 390 } 391 391 392 function _jsdoc_cron_timeout(){ 393 static $start; 394 static $count; 395 if (!$start) { 396 $start = time(); 397 return false; 398 } 399 ++$count; 400 $delta = time() - $start; 401 $avg = $delta / $count; 402 $estimate = $delta + $avg; 403 if ($estimate > 30) { 404 return true; 405 } 406 return false; 407 } 408 392 409 /** 393 410 * Implementation of hook_cron(). … … 409 426 // Use the configuration settings to switch directories, and load the plugin file 410 427 _jsdoc_cron_chdir(true); 428 _jsdoc_cron_timeout(); 411 429 412 430 // Validate the stuff added in the newly included file 413 431 if (_jsdoc_cron_validate_include()) { 414 432 $files = variable_get('jsdoc_cron_files', array()); 415 $limit = 25;416 433 if (!empty($files)) { 417 434 call_user_func(_jsdoc_base() . '_get_files'); … … 426 443 } 427 444 428 if(count($files) <= $limit){429 variable_set('jsdoc_cron_files', array());430 }else{431 variable_set('jsdoc_cron_files', array_slice($files, $limit));432 }433 434 445 if (!is_array($files)) { 435 446 watchdog('jsdoc', _jsdoc_base() . '_get_files' . t(' does not return an array in ') . _jsdoc_file_location(), WATCHDOG_ERROR); … … 449 460 450 461 $count = 0; 451 foreach ($files as $list) { 452 if($count == $limit){ 462 while (count($files)) { 463 $list = array_shift($files); 464 465 if (_jsdoc_cron_timeout()) { 453 466 break; 454 467 } 468 else{ 469 variable_set('jsdoc_cron_files', $files); 470 if (empty($files)) { 471 break; 472 } 473 } 474 455 475 ++$count; 456 476 list($namespace, $file_name) = $list; … … 560 580 } 561 581 } 582 583 $files = variable_get('jsdoc_cron_files', array()); 562 584 } 563 585