<commit_before>'use strict';

/**
 * @license
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

goog.provide('tachyfont.WorkQueue');

goog.require('tachyfont.Reporter');



/**
 * This class manages TachyFont work queues.
 * @param {string} name An identifier useful for error reports.
 * @constructor @struct @final
 */
tachyfont.WorkQueue = function(name) {
  /**
   * An identifier useful for error reports.
   * @private @const {string}
   */
  this.name_ = name;
};


/**
 * Enum for error values.
 * @enum {string}
 */
tachyfont.WorkQueue.Error = {
  FILE_ID: 'EWQ',
  END: '00'
};


/**
 * The error reporter for this file.
 * @param {string} errNum The error number;
 * @param {string} errId Identifies the error.
 * @param {*} errInfo The error object;
 */
tachyfont.WorkQueue.reportError = function(errNum, errId, errInfo) {
  tachyfont.Reporter.reportError(
      tachyfont.WorkQueue.Error.FILE_ID + errNum, errId, errInfo);
};


/**
 * Gets the work queue name
 * @return {string}
 */
tachyfont.WorkQueue.prototype.getName = function() {
  return this.name_;
};<commit_msg>Add a Task class. To WorkQueue add an addTask call.<commit_after>'use strict';

/**
 * @license
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

goog.provide('tachyfont.WorkQueue');

goog.require('tachyfont.Reporter');



/**
 * This class manages work queues.
 * @param {string} name An identifier useful for error reports.
 * @constructor @struct @final
 */
tachyfont.WorkQueue = function(name) {
  /** @private @const {string} */
  this.name_ = name;

  /** @private {!Array<!tachyfont.WorkQueue.Task>} */
  this.queue_ = [];
};


/**
 * Adds a task.
 * @param {!tachyfont.WorkQueue.Task} task The task to add.
 */
tachyfont.WorkQueue.prototype.addTask = function(task) {
  this.queue_.push(task);
};


/**
 * Gets the queue length.
 * @return {number}
 */
tachyfont.WorkQueue.prototype.getLength = function() {
  return this.queue_.length;
};


/**
 * Enum for error values.
 * @enum {string}
 */
tachyfont.WorkQueue.Error = {
  FILE_ID: 'EWQ',
  END: '00'
};


/**
 * The error reporter for this file.
 * @param {string} errNum The error number;
 * @param {string} errId Identifies the error.
 * @param {*} errInfo The error object;
 */
tachyfont.WorkQueue.reportError = function(errNum, errId, errInfo) {
  tachyfont.Reporter.reportError(
      tachyfont.WorkQueue.Error.FILE_ID + errNum, errId, errInfo);
};


/**
 * Gets the work queue name
 * @return {string}
 */
tachyfont.WorkQueue.prototype.getName = function() {
  return this.name_;
};



/**
 * A class that holds a task.
 * @param {function(*=)} taskFunction The function to call.
 * @param {*} data The data to pass to the function.
 * @constructor @struct @final
 */
tachyfont.WorkQueue.Task = function(taskFunction, data) {
  /** @private {function(*=)} */
  this.function_ = taskFunction;

  /** @private {*} */
  this.data_ = data;
};


/**
 * Gets the task function.
 * @return {function(*=)}
 */
tachyfont.WorkQueue.Task.prototype.getFunction = function() {
  return this.function_;
};


/**
 * Gets the task data.
 * @return {*}
 */
tachyfont.WorkQueue.Task.prototype.getData = function() {
  return this.data_;
};
{'fraction_non_alphanumeric': 0.13430343511450382, 'fraction_numerical': 0.0028625954198473282, 'mean_word_length': 3.658888888888889, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4225810', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1279, 'n_words': 418}