Ardour  8.12
io_tasklist.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef _ardour_io_tasklist_h_
20 #define _ardour_io_tasklist_h_
21 
22 #include <atomic>
23 #include <boost/function.hpp>
24 #include <vector>
25 #include <glibmm/threads.h>
26 
27 #include "pbd/semutils.h"
28 
30 
31 namespace ARDOUR
32 {
33 
35 {
36 public:
37  IOTaskList (uint32_t);
39 
41  void process ();
42  void push_back (boost::function<void ()> fn);
43 
44 private:
45  static void* _worker_thread (void*);
46 
47  void io_thread ();
48 
49  std::vector<boost::function<void ()>> _tasks;
50 
51  uint32_t _n_threads;
52  std::atomic<uint32_t> _n_workers;
53  std::vector<pthread_t> _workers;
54  std::atomic <bool> _terminate;
57  Glib::Threads::Mutex _tasks_mutex;
58 };
59 
60 } // namespace ARDOUR
61 #endif
std::atomic< uint32_t > _n_workers
Definition: io_tasklist.h:52
PBD::Semaphore _exec_sem
Definition: io_tasklist.h:55
static void * _worker_thread(void *)
IOTaskList(uint32_t)
std::vector< pthread_t > _workers
Definition: io_tasklist.h:53
Glib::Threads::Mutex _tasks_mutex
Definition: io_tasklist.h:57
std::atomic< bool > _terminate
Definition: io_tasklist.h:54
void push_back(boost::function< void()> fn)
uint32_t _n_threads
Definition: io_tasklist.h:51
PBD::Semaphore _idle_sem
Definition: io_tasklist.h:56
std::vector< boost::function< void()> > _tasks
Definition: io_tasklist.h:49
#define LIBARDOUR_API