<commit_before>package simizer.processor.tasks;

import simizer.VM;
import simizer.processor.events.IOTaskEvent;
import simizer.storage.IOType;
import simizer.storage.Resource;

/**
 * Task for reading or writing data to a disk.
 *
 * @author isep
 */
public class DiskTask extends IOTask {

  private final IOType type;
  private final Resource r;

  public DiskTask(int sz, Resource res, IOType type) {
    super(sz);

    this.r = res;
    this.type = type;
  }

  public IOType getType() {
    return type;
  }

  public Resource getResource() {
    return r;
  }

  /**
   * Registers an IOTaskEvent through the given virtual machine event producer.
   *
   * @param vm
   * @param timestamp
   */
  @Override
  public void startTask(VM vm, long timestamp) {
    long timing = vm.getTaskLength(this);

    vm.registerEvent(
        new IOTaskEvent(timestamp + timing, this, vm.getProcessingUnit()));
  }
}<commit_msg>Add documentation to the DiskTask class.<commit_after>package simizer.processor.tasks;

import simizer.VM;
import simizer.processor.TaskProcessor;
import simizer.processor.events.IOTaskEvent;
import simizer.storage.IOType;
import simizer.storage.Resource;

/**
 * A task for writing/reading data to/from a disk.
 * <p>
 * Simulates the latency present in reading/writing files from a disk.  Because
 * the processor is free to perform other tasks while the {@code StorageElement}
 * is retrieving data, this {@code Task} can run in parallel with
 * processor-intensive tasks.
 */
public class DiskTask extends IOTask {

  /** The resource to read or write. */
  private final Resource resource;

  /** The type of action to take with the resource. */
  private final IOType type;

  /**
   * Initializes a new {@code DiskTask}.
   * <p>
   * When run, this task will simulate performing the specified action on the
   * specified resource, and it will send an {@link IOTaskEvent} upon
   * completion.
   *
   * @param size the size of the resource being modified
   * @param resource the actual resource being modified
   * @param type the type of action that should be taken with the resource
   */
  public DiskTask(int size, Resource resource, IOType type) {
    super(size);

    this.resource = resource;
    this.type = type;
  }

  /**
   * Returns the type of operation that will be taken with the {@code Task}.
   *
   * @return the type of operation that will be taken with the {@code Task}
   */
  public IOType getType() {
    return type;
  }

  /**
   * Returns the resource that will be modified with the {@code Task}.
   *
   * @return the resource that will be modified with the {@code Task}
   */
  public Resource getResource() {
    return resource;
  }

  /**
   * {@inheritDoc}
   * <p>
   * When the task is complete, it triggers an event of type {@link
   * IOTaskEvent}.  (The event is given the {@link TaskProcessor} for the
   * specified {@link VM}.)
   *
   * @param vm the {@code VM} on which the task is run
   * @param timestamp the time when the task is run
   */
  @Override
  public void startTask(VM vm, long timestamp) {
    long timing = vm.getTaskLength(this);

    vm.registerEvent(
        new IOTaskEvent(timestamp + timing, this, vm.getProcessingUnit()));
  }
}
{'fraction_non_alphanumeric': 0.09389525875426093, 'fraction_numerical': 0.0, 'mean_word_length': 3.1705426356589146, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5888487', 'n_tokens_mistral': 952, 'n_tokens_neox': 931, 'n_words': 367}