]> source.dussan.org Git - nextcloud-server.git/commitdiff
Backgroundjobs: rename ScheduledTask to QueuedTask
authorJakob Sack <mail@jakobsack.de>
Thu, 9 Aug 2012 17:04:04 +0000 (19:04 +0200)
committerJakob Sack <mail@jakobsack.de>
Thu, 9 Aug 2012 17:04:04 +0000 (19:04 +0200)
lib/backgroundjob/scheduledtask.php
lib/backgroundjob/worker.php
lib/public/backgroundjob.php

index 47f332a204a3b1b3dadae2eb40c6ed8a04156c49..da5d4ddc6940c2e40111af6baf5f9d3ec7826e4d 100644 (file)
 */
 
 /**
- * This class manages our scheduled tasks.
+ * This class manages our queued tasks.
  */
-class OC_BackgroundJob_ScheduledTask{
+class OC_BackgroundJob_QueuedTask{
        /**
-        * @brief Gets one scheduled task
+        * @brief Gets one queued task
         * @param $id ID of the task
         * @return associative array
         */
        public static function find( $id ){
-               $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*scheduledtasks WHERE id = ?' );
+               $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*queuedtasks WHERE id = ?' );
                $result = $stmt->execute(array($id));
                return $result->fetchRow();
        }
 
        /**
-        * @brief Gets all scheduled tasks
+        * @brief Gets all queued tasks
         * @return array with associative arrays
         */
        public static function all(){
@@ -44,18 +44,17 @@ class OC_BackgroundJob_ScheduledTask{
                $return = array();
 
                // Get Data
-               $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*scheduledtasks' );
+               $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*queuedtasks' );
                $result = $stmt->execute(array());
                while( $row = $result->fetchRow()){
                        $return[] = $row;
                }
 
-               // Und weg damit
                return $return;
        }
 
        /**
-        * @brief Gets all scheduled tasks of a specific app
+        * @brief Gets all queued tasks of a specific app
         * @param $app app name
         * @return array with associative arrays
         */
@@ -64,7 +63,7 @@ class OC_BackgroundJob_ScheduledTask{
                $return = array();
 
                // Get Data
-               $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*scheduledtasks WHERE app = ?' );
+               $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*queuedtasks WHERE app = ?' );
                $result = $stmt->execute(array($app));
                while( $row = $result->fetchRow()){
                        $return[] = $row;
@@ -75,7 +74,7 @@ class OC_BackgroundJob_ScheduledTask{
        }
 
        /**
-        * @brief schedules a task
+        * @brief queues a task
         * @param $app app name
         * @param $klass class name
         * @param $method method name
@@ -83,21 +82,21 @@ class OC_BackgroundJob_ScheduledTask{
         * @return id of task
         */
        public static function add( $task, $klass, $method, $parameters ){
-               $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*scheduledtasks (app, klass, method, parameters) VALUES(?,?,?,?)' );
+               $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*queuedtasks (app, klass, method, parameters) VALUES(?,?,?,?)' );
                $result = $stmt->execute(array($app, $klass, $method, $parameters, time));
 
                return OC_DB::insertid();
        }
 
        /**
-        * @brief deletes a scheduled task
+        * @brief deletes a queued task
         * @param $id id of task
         * @return true/false
         *
         * Deletes a report
         */
        public static function delete( $id ){
-               $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*scheduledtasks WHERE id = ?' );
+               $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*queuedtasks WHERE id = ?' );
                $result = $stmt->execute(array($id));
 
                return true;
index 799fa5306c65bbd54dd0a3e807b28cadfb5be8d8..0acbb9d32172ebc30b32de88b67cb32469097de9 100644 (file)
@@ -30,7 +30,7 @@ class OC_BackgroundJob_Worker{
         * @brief executes all tasks
         * @return boolean
         *
-        * This method executes all regular tasks and then all scheduled tasks.
+        * This method executes all regular tasks and then all queued tasks.
         * This method should be called by cli scripts that do not let the user
         * wait.
         */
@@ -41,11 +41,11 @@ class OC_BackgroundJob_Worker{
                        call_user_func( $value );
                }
 
-               // Do our scheduled tasks
-               $scheduled_tasks = OC_BackgroundJob_ScheduledTask::all();
-               foreach( $scheduled_tasks as $task ){
+               // Do our queued tasks
+               $queued_tasks = OC_BackgroundJob_QueuedTask::all();
+               foreach( $queued_tasks as $task ){
                        call_user_func( array( $task['klass'], $task['method'] ), $task['parameters'] );
-                       OC_BackgroundJob_ScheduledTask::delete( $task['id'] );
+                       OC_BackgroundJob_QueuedTask::delete( $task['id'] );
                }
                
                return true;
@@ -82,23 +82,23 @@ class OC_BackgroundJob_Worker{
                        }
 
                        if( $done == false ){
-                               // Next time load scheduled tasks
-                               OC_Appconfig::setValue( 'core', 'backgroundjobs_step', 'scheduled_tasks' );
+                               // Next time load queued tasks
+                               OC_Appconfig::setValue( 'core', 'backgroundjobs_step', 'queued_tasks' );
                        }
                }
                else{
-                       $tasks = OC_BackgroundJob_ScheduledTask::all();
+                       $tasks = OC_BackgroundJob_QueuedTask::all();
                        if( count( $tasks )){
                                $task = $tasks[0];
                                // delete job before we execute it. This prevents endless loops
                                // of failing jobs.
-                               OC_BackgroundJob_ScheduledTask::delete($task['id']);
+                               OC_BackgroundJob_QueuedTask::delete($task['id']);
 
                                // execute job
                                call_user_func( array( $task['klass'], $task['method'] ), $task['parameters'] );
                        }
                        else{
-                               // Next time load scheduled tasks
+                               // Next time load queued tasks
                                OC_Appconfig::setValue( 'core', 'backgroundjobs_step', 'regular_tasks' );
                                OC_Appconfig::setValue( 'core', 'backgroundjobs_task', '' );
                        }
index ac863634540aa4ffbb379e4dbe567b4e83e69d95..72f4557eb1adb9deed3b9300fb0f188c2fbc66f3 100644 (file)
@@ -32,19 +32,20 @@ namespace OCP;
  * This class provides functions to manage backgroundjobs in ownCloud
  *
  * There are two kind of background jobs in ownCloud: regular tasks and
- * scheduled tasks.
+ * queued tasks.
  *
  * Regular tasks have to be registered in appinfo.php and
  * will run on a regular base. Fetching news could be a task that should run
  * frequently.
  *
- * Scheduled tasks have to be registered each time you want to execute them.
- * An example of the scheduled task would be the creation of the thumbnail. As
- * soon as the user uploads a picture the gallery app registers the scheduled
- * task "create thumbnail" and saves the path in the parameter. As soon as the
- * task is done it will be deleted from the list.
+ * Queued tasks have to be registered each time you want to execute them.
+ * An example of the queued task would be the creation of the thumbnail. As
+ * soon as the user uploads a picture the gallery app registers the queued
+ * task "create thumbnail" and saves the path in the parameter instead of doing
+ * the work right away. This makes the app more responsive. As soon as the task 
+ * is done it will be deleted from the list.
  */
-class Backgroundjob {
+class BackgroundJob {
        /**
         * @brief creates a regular task
         * @param $klass class name
@@ -66,51 +67,51 @@ class Backgroundjob {
        }
 
        /**
-        * @brief Gets one scheduled task
+        * @brief Gets one queued task
         * @param $id ID of the task
         * @return associative array
         */
-       public static function findScheduledTask( $id ){
-               return \OC_BackgroundJob_ScheduledTask::find( $id );
+       public static function findQueuedTask( $id ){
+               return \OC_BackgroundJob_QueuedTask::find( $id );
        }
 
        /**
-        * @brief Gets all scheduled tasks
+        * @brief Gets all queued tasks
         * @return array with associative arrays
         */
-       public static function allScheduledTasks(){
-               return \OC_BackgroundJob_ScheduledTask::all();
+       public static function allQueuedTasks(){
+               return \OC_BackgroundJob_QueuedTask::all();
        }
 
        /**
-        * @brief Gets all scheduled tasks of a specific app
+        * @brief Gets all queued tasks of a specific app
         * @param $app app name
         * @return array with associative arrays
         */
-       public static function scheduledTaskWhereAppIs( $app ){
-               return \OC_BackgroundJob_ScheduledTask::whereAppIs( $app );
+       public static function queuedTaskWhereAppIs( $app ){
+               return \OC_BackgroundJob_QueuedTask::whereAppIs( $app );
        }
 
        /**
-        * @brief schedules a task
+        * @brief queues a task
         * @param $app app name
         * @param $klass class name
         * @param $method method name
         * @param $parameters all useful data as text
         * @return id of task
         */
-       public static function addScheduledTask( $task, $klass, $method, $parameters ){
-               return \OC_BackgroundJob_ScheduledTask::add( $task, $klass, $method, $parameters );
+       public static function addQueuedTask( $task, $klass, $method, $parameters ){
+               return \OC_BackgroundJob_QueuedTask::add( $task, $klass, $method, $parameters );
        }
 
        /**
-        * @brief deletes a scheduled task
+        * @brief deletes a queued task
         * @param $id id of task
         * @return true/false
         *
         * Deletes a report
         */
-       public static function deleteScheduledTask( $id ){
-               return \OC_BackgroundJob_ScheduledTask::delete( $id );
+       public static function deleteQueuedTask( $id ){
+               return \OC_BackgroundJob_QueuedTask::delete( $id );
        }
 }