Learn R Programming

taskqueue (version 0.2.0)

task_add: Add Tasks to a Project

Description

Creates a specified number of tasks in a project's task table. Each task is assigned a unique ID and initially has idle (NULL) status.

Usage

task_add(project, num, clean = TRUE, con = NULL)

Value

Invisibly returns NULL. Called for side effects (adding tasks to database).

Arguments

project

Character string specifying the project name.

num

Integer specifying the number of tasks to create.

clean

Logical indicating whether to delete existing tasks before adding new ones. Default is TRUE.

con

An optional database connection. If NULL, a new connection is created and closed automatically.

Details

Tasks are created with sequential IDs from 1 to num. Each task initially has NULL status (idle) and will be assigned to workers after the project is started.

If clean = TRUE, all existing tasks are removed using task_clean before adding new tasks. If FALSE, new tasks are added but existing tasks remain (duplicates are ignored due to primary key constraints).

Your worker function will receive the task ID as its first argument.

See Also

task_clean, task_status, worker, project_start

Examples

Run this code
if (FALSE) {
# Not run:
# Add 100 tasks to a project
task_add("simulation_study", num = 100)

# Add tasks without cleaning existing ones
task_add("simulation_study", num = 50, clean = FALSE)

# Check task status
task_status("simulation_study")
}

Run the code above in your browser using DataLab