2017 © Pedro Peláez
 

library task_waiter

Waiting for a task in other php process complete

image

madnh/task_waiter

Waiting for a task in other php process complete

  • Thursday, March 2, 2017
  • by madnh
  • Repository
  • 1 Watchers
  • 0 Stars
  • 90 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Task Waiter

This class help to detect tasks in multiple simultaneous processes were completed or not., (*1)

Install

Composer, (*2)

composer require madnh/task_waiter

Properties

  • static::$savePath: place to save task files

Methods

  • static::start($taskName): start a task, other comming php process will hold until this task is complete or current process finished.
  • static::isWorking($taskName): check if a task is running in any of process.
  • static::complete($taskName): set status of a task is complete. Other processes can continue their business.

Example

Run below example in multiple command prompts, (*3)

use MaDnh\TaskWaiter\TaskWaiter as Task;

echo "Start example\n";
$task = 'example_task';

//Task::$savePath = __DIR__;

echo Task::isWorking($task) ? "Task is running in other process" : 'Task is free';

print "\n";

if (Task::start($task)) {
    echo "Task is in processing!\n";

    sleep(5);
    Task::complete($task);

    echo "Task complete!\n";
    echo "Do other process!\n";

    sleep(5);
} else {
    echo "Start failed";
}

echo "Bye!";

Example result image, (*4)

Example result, (*5)

The Versions

02/03 2017

dev-master

9999999-dev

Waiting for a task in other php process complete

  Sources   Download

MIT

02/03 2017

0.1

0.1.0.0

Waiting for a task in other php process complete

  Sources   Download

MIT