Index: api.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/api/api.info,v
retrieving revision 1.6.2.4
diff -u -r1.6.2.4 api.info
--- api.info	15 Apr 2010 06:38:10 -0000	1.6.2.4
+++ api.info	18 Apr 2010 17:50:56 -0000
@@ -3,7 +3,7 @@
 description = Generates and displays API documentation pages.
 package = Development
 core = 6.x
-dependencies[] = job_queue
+dependencies[] = drupal_queue
 dependencies[] = node
 dependencies[] = grammar_parser
 dependencies[] = ctools
Index: api.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/api/api.module,v
retrieving revision 1.88.2.85
diff -u -r1.88.2.85 api.module
--- api.module	15 Apr 2010 06:38:10 -0000	1.88.2.85
+++ api.module	18 Apr 2010 17:50:56 -0000
@@ -531,6 +531,22 @@
 }
 
 /**
+ * Implementation of hook_cron_queue_info().
+ */
+function api_cron_queue_info() {
+  return array(
+    'api_parse' => array(
+      'worker callback' => 'api_queue_parse_file',
+      'time' => 15,
+    ),
+    'api_delete' => array(
+      'worker callback' => 'api_queue_file_delete',
+      'time' => 15,
+    ),
+  );
+}
+
+/**
  * Menu object load callback for %api_filename in menu paths.
  *
  * Loads information about an API file.
@@ -1885,3 +1901,24 @@
   $name = array_shift($words);
   return api_link_name($name, $branch, $prepend, $append, implode(' ', $words), TRUE);
 }
+
+/**
+ * Parse queued files
+ */
+function api_queue_parse_file($data) {
+  module_load_include('inc', 'api', 'parser');
+  
+  api_parse_file($data['parser'], $data['path'], $data['branch'], $data['file']);
+  watchdog('api', 'API parse %branch %file', array('%branch' => $data['branch_name'], '%file' => $data['file']));
+}
+
+/**
+ * Process any file deletes to remove any obsolete js index files.
+ *
+ * @param $data
+ *   Data past by queue. 
+ */
+function api_queue_file_delete($data) {
+  file_delete($data['path']);
+  watchdog('api', 'Remove expired API JSON, %path.', array('%path' => $data['path']));
+}
\ No newline at end of file
Index: parser.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/api/parser.inc,v
retrieving revision 1.41.2.56
diff -u -r1.41.2.56 parser.inc
--- parser.inc	10 Apr 2010 05:43:16 -0000	1.41.2.56
+++ parser.inc	18 Apr 2010 17:50:57 -0000
@@ -763,6 +763,8 @@
 
   $directory = file_directory_path();
   if (is_dir($directory) && is_writable($directory) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC)) {
+    drupal_queue_include();
+    
     $path = file_create_path('api');
     file_check_directory($path, FILE_CREATE_DIRECTORY);
     $date = gmdate('U');
@@ -775,7 +777,8 @@
           continue; // No changes, no file write.
         }
         // Delete in the future, help avoid race conditions.
-        job_queue_add('file_delete', t('Remove expired API JSON, %path.'), array('%path' => $old_file_path));
+        $queue = DrupalQueue::get('api_delete');
+        $queue->createItem(array('path' => $old_file_path));
       }
 
       $file_name = $path . '/api-' . $branch_name . '-' . $date . '.json';
@@ -873,7 +876,10 @@
         $parse = TRUE;
       }
       if ($parse) {
-        job_queue_add('api_parse_file', t('API parse %branch %file'), array($parse_functions[$matches[1]], $path, $branch, '%file' => $file_name, '%branch' => $branch->branch_name), drupal_get_path('module', 'api') .'/parser.inc', TRUE);
+        drupal_queue_include();
+        
+        $queue = DrupalQueue::get('api_parse');
+        $queue->createItem(array('parser' => $parse_functions[$matches[1]], 'path' => $path, 'branch' => $branch, 'file' => $file_name, 'branch_name' => $branch->branch_name));
       }
     }
   }
Index: tests/api_test_case.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/api/tests/api_test_case.php,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 api_test_case.php
--- tests/api_test_case.php	14 Apr 2010 05:14:53 -0000	1.1.2.9
+++ tests/api_test_case.php	18 Apr 2010 17:50:57 -0000
@@ -7,10 +7,12 @@
   function setUp() {
     $this->default_branch = variable_get('api_default_branch', NULL);
     variable_del('api_default_branch');
-    parent::setUp('job_queue', 'grammar_parser', 'api');
+    parent::setUp('drupal_queue', 'grammar_parser', 'api');
 
     include drupal_get_path('module', 'api') .'/api.admin.inc';
     include drupal_get_path('module', 'api') .'/parser.inc';
+    
+    drupal_queue_include();
 
     // Make a branch for sample code.
     $branch = new stdClass();
@@ -27,7 +29,25 @@
 
     // Parse the code.
     api_update_all_branches();
-    while (job_queue_dequeue()) { }
+    
+    // We only want the api queues so call the api implementation of hook_cron_queue_info().
+    $queues = api_cron_queue_info();
+    
+    // But we still want to call the hook_cron_queue_alter().
+    drupal_alter('cron_queue_info', $queues);
+    
+    
+    foreach ($queues as $queue_name => $info) {
+      $function = $info['worker callback'];
+      $end = time() + (isset($info['time']) ? $info['time'] : 15);
+      $queue = DrupalQueue::get($queue_name);
+      while (time() < $end && ($item = $queue->claimItem())) {
+        $this->assertTrue(TRUE, t('Processing queue %queue - file %path', array('%queue' => $queue_name, '%path' => $item->data['path'])));
+        $function($item->data);
+        $queue->deleteItem($item);
+      }
+    }
+    
     api_shutdown();
 
     api_get_branches(TRUE);
