<commit_before>/**
 * @file process_manager.c
 * @author <NAME> <<EMAIL>>
 * 
 * @section LICENSE
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the author nor the
 *    names of its contributors may be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * @section DESCRIPTION
 * 
 * Module which allows starting and stopping processes from templates dynamically.
 * 
 * Synopsis:
 *   process_manager()
 * 
 * Description:
 *   Manages processes. On deinitialization, initiates termination of all
 *   contained processes and waits for them to terminate.
 * 
 * Synopsis:
 *   process_manager::start(name, string template_name, list args)
 * 
 * Description:
 *   Creates a new process from the template named template_name, with arguments args,
 *   identified by name within the process manager. If a process with this name already exists
 *   and is not being terminated, does nothing. If it is being terminated, it will be restarted
 *   using the given parameters after it terminates.
 *   The process can access objects as seen from the process_manager() statement via _caller.
 * 
 * Synopsis:
 *   process_manager::stop(name)
 * 
 * Description:
 *   Iinitiates termination of the process identified by name within the process manager.
 *   If there is no such process, or the process is already being terminated, does nothing.
 */

#include <stdlib.h>
#include <string.h>

#include <misc/offset.h>
#include <misc/debug.h>
#include <misc/strdup.h>
#include <misc/balloc.h>
#include <structure/LinkedList1.h>
#include <ncd/NCDModule.h>
#include <ncd/extra/value_utils.h><commit_msg>ncd: modules: process_manager: improve documentation<commit_after>/**
 * @file process_manager.c
 * @author <NAME> <<EMAIL>>
 * 
 * @section LICENSE
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the author nor the
 *    names of its contributors may be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * @section DESCRIPTION
 * 
 * Module which allows starting and controlling template processes using an imperative
 * interface.
 * 
 * Synopsis:
 *   process_manager()
 * 
 * Description:
 *   Represents a set of managed processes. Each process has a "name", which is a value
 *   that uniquely identifies it within its process manager.
 *   When deinitialization is requested, requests termination of all managed processes
 *   and waits for all of them to terminate before deinitializing.
 *   Managed processes can access objects as seen from the process_manager() statement
 *   via the special _caller object.
 * 
 * Synopsis:
 *   process_manager::start(name, string template_name, list args)
 * 
 * Description:
 *   Creates a new process from the template named 'template_name', with arguments 'args',
 *   identified by 'name' within the process manager. If a process with this name already exists
 *   and is not being terminated, does nothing. If it exists and is being terminated, it will
 *   be restarted using the given parameters after it terminates.
 *   If the process does not exist, it is created immediately, and the immediate effects
 *   of the process being created happnen before the immediate effects of the start()
 *   statement going up.
 * 
 * Synopsis:
 *   process_manager::stop(name)
 * 
 * Description:
 *   Initiates termination of the process identified by 'name' within the process manager.
 *   If there is no such process, or the process is already being terminated, does nothing.
 *   If the process does exist and is not already being terminated, termination of the
 *   process is requested, and the immediate effects of the termination request happen
 *   before the immediate effects of the stop() statement going up.
 */

#include <stdlib.h>
#include <string.h>

#include <misc/offset.h>
#include <misc/debug.h>
#include <misc/strdup.h>
#include <misc/balloc.h>
#include <structure/LinkedList1.h>
#include <ncd/NCDModule.h>
#include <ncd/extra/value_utils.h>
{'fraction_non_alphanumeric': 0.06378097277454879, 'fraction_numerical': 0.001223615784643622, 'mean_word_length': 4.100624024960998, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '7294147', 'n_tokens_mistral': 1743, 'n_tokens_neox': 1584, 'n_words': 841}