Ardour  9.0-pre0-582-g084a23a80d
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 <vector>
24 #include <glibmm/threads.h>
25 
26 #include "pbd/semutils.h"
27 
29 
30 namespace ARDOUR
31 {
32 
34 {
35 public:
36  IOTaskList (uint32_t);
38 
40  void process ();
41  void push_back (std::function<void ()> fn);
42 
43 private:
44  static void* _worker_thread (void*);
45 
46  void io_thread ();
47 
48  std::vector<std::function<void ()>> _tasks;
49 
50  uint32_t _n_threads;
51  std::atomic<uint32_t> _n_workers;
52  std::vector<pthread_t> _workers;
53  std::atomic <bool> _terminate;
56  Glib::Threads::Mutex _tasks_mutex;
57 };
58 
59 } // namespace ARDOUR
60 #endif
std::atomic< uint32_t > _n_workers
Definition: io_tasklist.h:51
PBD::Semaphore _exec_sem
Definition: io_tasklist.h:54
static void * _worker_thread(void *)
IOTaskList(uint32_t)
std::vector< pthread_t > _workers
Definition: io_tasklist.h:52
Glib::Threads::Mutex _tasks_mutex
Definition: io_tasklist.h:56
std::atomic< bool > _terminate
Definition: io_tasklist.h:53
void push_back(std::function< void()> fn)
std::vector< std::function< void()> > _tasks
Definition: io_tasklist.h:48
uint32_t _n_threads
Definition: io_tasklist.h:50
PBD::Semaphore _idle_sem
Definition: io_tasklist.h:55
#define LIBARDOUR_API