/*
* Copyright © 2004 Ondra Kamenik
* Copyright © 2019 Dynare Team
*
* This file is part of Dynare.
*
* Dynare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dynare is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dynare. If not, see .
*/
// Simple threads.
/* This file defines types making a simple interface to multi-threading.
The file provides the following interfaces:
— detach_thread is a pure virtual class, which must be inherited and a
method operator()() be implemented as the running code of the thread.
— detach_thread_group allows insertion of detach_thread’s and running all of
them simultaneously. The threads are not joined, they are synchronized by
means of a counter counting running threads. A change of the counter is
checked by waiting on an associated condition. The number of maximum
parallel threads can be controlled. See below. The group also provides a
mutex to be shared between the workers for their own synchronization
purposes.
The number of maximum parallel threads is controlled via a static member of
the detach_thread_group class. */
#ifndef STHREAD_H
#define STHREAD_H
#include
#include