Created
April 14, 2020 08:18
-
-
Save fjugaldev/e2c64a831b90861dfa676fea67d4097d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Threading\Task; | |
/** | |
* Clase abstracta de una tarea base la cual es heradada por todas las tareas | |
*/ | |
abstract class BaseTask | |
{ | |
/** | |
* Initialize (Ejecutada de primera por el administrador de hilos) | |
* | |
* @return mixed | |
*/ | |
public function initialize() | |
{ | |
return true; | |
} | |
/** | |
* Ejecutada por el administrador de hilos si el proceso se completó con exito (Cuando el metodo process() haya retornado true) | |
* | |
* @return mixed | |
*/ | |
public function onSuccess() | |
{ | |
return true; | |
} | |
/** | |
* Ejecutada por el administrador de hilos si el proceso se completó con fallos (Cuando el metodo process() haya retornado false) | |
* | |
* @return mixed | |
*/ | |
public function onFailure() | |
{ | |
return false; | |
} | |
/** | |
* Método principal que contiene la lógica a ser ejecutada por la tarea | |
* | |
* @param $params array Array asociativo de parametros | |
* | |
* @return boolean True para Éxito, false de lo contrario | |
*/ | |
abstract public function process(array $params = array()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment