Subject | Hash | Author | Date (UTC) |
---|---|---|---|
thread pool cleanup | 0b783f47cd02fb118f299784b52209e259646b25 | Your Name | 2019-11-25 03:23:02 |
removed nodiscard for optional function | 3ba7da3a20d2ef5e8bc70d1ff14b9db973bba0dd | Your Name | 2019-11-25 03:22:13 |
rarray allocation fix | e192f65d453e4e858bc0c034b5b431591175886d | Your Name | 2019-11-25 03:20:49 |
new darray function | 41ed65d9c71ba226572b451f487ac381bdcb382d | Your Name | 2019-11-25 03:20:26 |
threads wrapper and thread pool moved to jlib | e902ab04f388b331f7b0201a01591c52c0fb44a5 | Your Name | 2019-11-25 02:11:05 |
sharray implementation | 84f563f018049700a9aaa3d9b915cd8e60010d6a | Your Name | 2019-11-25 02:10:39 |
removed excess cmake variable | 5391e7b7eb08e7aef83e7b3783c3eb405b701f99 | Your Name | 2019-11-25 02:09:41 |
max and min functions | 9aee2d76ffc74c9ff5e9b10591b4b5a77de8a859 | Your Name | 2019-11-25 02:09:16 |
item_call uses call func instead of constructor, so refference or copy can be passed and added conditional removing in darray | 4caca92c89f8945a937e9fe6d5c8634ffc6b0af1 | Your Name | 2019-11-25 02:08:08 |
sharray work in progress | 440da36f73077f6b7eec359d0059d1b1df96b295 | Your Name | 2019-11-24 21:47:22 |
darray protected members renamed | b4ade511fd87dcb002a787ccc1c38143b09a5d04 | Your Name | 2019-11-24 21:46:41 |
built_const function not work with inheritance, so overloaded again | 3ea48400586ef4dca2fe218dd7b1187a5842e879 | Your Name | 2019-11-24 20:41:48 |
added missing nodiscard attributes | 592e615e8dbca2d0a5595753e35f59bf100d164f | Your Name | 2019-11-24 20:41:13 |
io_agent_memory updated | 80d60ca831656db3ce47ecb21afb9cea89afe373 | Your Name | 2019-11-24 20:40:42 |
item_call now uses function pointers instead of limited methods | 5e5a56a57c9d7125688f059de7eaf826dcd6dac7 | Your Name | 2019-11-24 20:26:59 |
init_move for const version | 97e9eea70283e63beb10a90518ff589e8e58d0d8 | Your Name | 2019-11-23 01:54:17 |
io_agent_fs for working stream using io_agent | 4e1e455b70935abba6d8a5349c725c4ee903087e | Your Name | 2019-11-23 01:16:10 |
io_agent_mem more features | 0885fdf18edf22e95acda127fc7be29dc5b11f37 | Your Name | 2019-11-23 01:13:46 |
string more features | d3fd117f9f4b7629d62bb7759c3a4254646f05e5 | Your Name | 2019-11-23 01:13:10 |
rarray.h new functions | c8903fd687d31f8271bfdc31a491a3fd3f9d53c6 | Your Name | 2019-11-23 00:56:53 |
File | Lines added | Lines deleted |
---|---|---|
include/jlib/thread_pool.h | 1 | 1 |
include/jlib/threads.h | 1 | 23 |
include/jlib/threads/thread_pool.h | 6 | 6 |
include/jlib/threads/thread_pool_queues.h | 3 | 33 |
include/jlib/threads/threads.h | 25 | 0 |
File include/jlib/thread_pool.h changed (mode: 100644) (index dff696f..1389e82) | |||
1 | 1 | #pragma once | #pragma once |
2 | 2 | ||
3 | #include "thread_pool.h" | ||
3 | #include "threads/thread_pool.h" |
File include/jlib/threads.h changed (mode: 100644) (index d9b19e4..477f83c) | |||
1 | 1 | #pragma once | #pragma once |
2 | 2 | ||
3 | #include "threads/def.h" | ||
4 | #include "threads/impl_pthreads.inl" | ||
5 | namespace jl::threads | ||
6 | { | ||
7 | template<typename Result> | ||
8 | using Thread = P_Thread<Result>; | ||
9 | |||
10 | using Spinlock_t = P_SpinLock_t; | ||
11 | using Mutex_t = P_Mutex_t; | ||
12 | |||
13 | using Mutex = P_Mutex; | ||
14 | using Spinlock = P_SpinLock; | ||
15 | using Condition = P_Condition; | ||
16 | |||
17 | template<LockType TYPE> | ||
18 | using Lock = typename std::conditional<TYPE == LockType::SpinLock, Spinlock, Mutex>::type; | ||
19 | |||
20 | inline size_t cpu_number(); | ||
21 | } | ||
22 | |||
23 | #include "threads/cpu_number.inl" | ||
24 | |||
25 | namespace jth = jl::threads; | ||
3 | #include "threads/threads.h" |
File include/jlib/threads/thread_pool.h changed (mode: 100644) (index 1b729fa..f72fdba) | |||
... | ... | namespace jl::threads | |
58 | 58 | ||
59 | 59 | data.stop_work = false; | data.stop_work = false; |
60 | 60 | ||
61 | for (size_t i = 0; i < threads.size; ++i) | ||
61 | for (size_t i = 0; i < threads.count(); ++i) | ||
62 | 62 | { | { |
63 | 63 | auto &fd = threads[i]; | auto &fd = threads[i]; |
64 | 64 | fd.is_dead = false; | fd.is_dead = false; |
... | ... | namespace jl::threads | |
101 | 101 | ||
102 | 102 | void wait_idle() | void wait_idle() |
103 | 103 | { | { |
104 | data.task_queues.queues.lock.lock(); | ||
104 | data.task_queues.queues_lock.lock(); | ||
105 | 105 | while (data.task_queues.has_tasks || data.task_queues.in_progress_count > 0) | while (data.task_queues.has_tasks || data.task_queues.in_progress_count > 0) |
106 | 106 | { | { |
107 | 107 | data.task_queues.brodcast_empty = true; | data.task_queues.brodcast_empty = true; |
108 | data.task_queues.idle_condition.wait(&data.task_queues.queues.lock); | ||
108 | data.task_queues.idle_condition.wait(&data.task_queues.queues_lock); | ||
109 | 109 | } | } |
110 | 110 | ||
111 | data.task_queues.queues.lock.unlock(); | ||
111 | data.task_queues.queues_lock.unlock(); | ||
112 | 112 | } | } |
113 | 113 | ||
114 | 114 | void stop() | void stop() |
... | ... | namespace jl::threads | |
122 | 122 | threads.destroy(); | threads.destroy(); |
123 | 123 | } | } |
124 | 124 | ||
125 | mtl::array::resizable<ThreadData> threads; | ||
126 | Data data; | ||
125 | rarray<ThreadData> threads; | ||
126 | Data data; | ||
127 | 127 | }; | }; |
128 | 128 | } | } |
File include/jlib/threads/thread_pool_queues.h changed (mode: 100644) (index 112b9f7..3c4be1e) | |||
... | ... | namespace jl::threads | |
35 | 35 | size_t sequential_task; | size_t sequential_task; |
36 | 36 | }; | }; |
37 | 37 | ||
38 | struct TaskQueue | ||
39 | { | ||
40 | void init() | ||
41 | { | ||
42 | tasks.init(); | ||
43 | } | ||
44 | |||
45 | void destroy() | ||
46 | { | ||
47 | tasks.destroy(); | ||
48 | } | ||
49 | |||
50 | [[nodiscard]] bool pop(Task *p_dst) | ||
51 | { | ||
52 | if (tasks.count() > 0) | ||
53 | { | ||
54 | *p_dst = tasks.last(); | ||
55 | tasks.remove_last(); | ||
56 | return true; | ||
57 | } | ||
58 | return false; | ||
59 | } | ||
60 | |||
61 | [[nodiscard]] bool push(const Task &task) | ||
62 | { | ||
63 | return tasks.insert(task); | ||
64 | } | ||
65 | |||
66 | darray<Task> tasks; | ||
67 | }; | ||
68 | 38 | ||
69 | 39 | struct TaskQueues | struct TaskQueues |
70 | 40 | { | { |
... | ... | namespace jl::threads | |
95 | 65 | { | { |
96 | 66 | bool result; | bool result; |
97 | 67 | queues_lock.lock(); | queues_lock.lock(); |
98 | result = queues[queue_i].push(task); | ||
68 | result = queues[queue_i].insert(task); | ||
99 | 69 | if (result || not has_tasks) | if (result || not has_tasks) |
100 | 70 | has_tasks = true, condition.wake_up_threads(); | has_tasks = true, condition.wake_up_threads(); |
101 | 71 | queues_lock.unlock(); | queues_lock.unlock(); |
... | ... | namespace jl::threads | |
132 | 102 | has_tasks = false; | has_tasks = false; |
133 | 103 | for (auto &queue : queues) | for (auto &queue : queues) |
134 | 104 | { | { |
135 | if (queue.pop(p_dst)) | ||
105 | if (queue.remove_last_if_exist(p_dst)) | ||
136 | 106 | { | { |
137 | 107 | has_tasks = true; | has_tasks = true; |
138 | 108 | ++in_progress_count; | ++in_progress_count; |
... | ... | namespace jl::threads | |
148 | 118 | return continue_to_work; | return continue_to_work; |
149 | 119 | } | } |
150 | 120 | ||
151 | jl::rarray<TaskQueue> queues; | ||
121 | jl::rarray<darray<Task>> queues; | ||
152 | 122 | Mutex queues_lock; | Mutex queues_lock; |
153 | 123 | size_t in_progress_count; | size_t in_progress_count; |
154 | 124 | Condition idle_condition; | Condition idle_condition; |
File include/jlib/threads/threads.h changed (mode: 100644) (index e69de29..2a1e8cc) | |||
1 | #pragma once | ||
2 | |||
3 | #include "def.h" | ||
4 | #include "impl_pthreads.inl" | ||
5 | namespace jl::threads | ||
6 | { | ||
7 | template<typename Result> | ||
8 | using Thread = P_Thread<Result>; | ||
9 | |||
10 | using Spinlock_t = P_SpinLock_t; | ||
11 | using Mutex_t = P_Mutex_t; | ||
12 | |||
13 | using Mutex = P_Mutex; | ||
14 | using Spinlock = P_SpinLock; | ||
15 | using Condition = P_Condition; | ||
16 | |||
17 | template<LockType TYPE> | ||
18 | using Lock = typename std::conditional<TYPE == LockType::SpinLock, Spinlock, Mutex>::type; | ||
19 | |||
20 | inline size_t cpu_number(); | ||
21 | } | ||
22 | |||
23 | #include "cpu_number.inl" | ||
24 | |||
25 | namespace jth = jl::threads; |