Skip to content

Commit e834142

Browse files
committed
thread: add render / render task thread types
1 parent 2dd0439 commit e834142

2 files changed

Lines changed: 42 additions & 5 deletions

File tree

src/ossia/detail/thread.cpp

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ std::string get_module_path()
243243

244244
#include <boost/unordered/concurrent_flat_map.hpp>
245245

246-
#include <bitset>
247246
namespace ossia
248247
{
249248
struct cpu_pin
@@ -255,13 +254,15 @@ struct cpu_pin
255254
uint8_t Audio : 1 = 0; // 'A',
256255
uint8_t AudioTask : 1 = 0; // = 'a',
257256
uint8_t Ui : 1 = 0; // = 'U',
258-
uint8_t UiTask : 1 = 0; // = 'u'
257+
uint8_t UiTask : 1 = 0; // = 'u',
258+
uint8_t Render: 1 = 0; // = 'R',
259+
uint8_t RenderTask : 1 = 0; // = 'r'
259260
};
260261

261-
static const ossia::small_vector<cpu_pin, 128>& parse_pins()
262+
static const ossia::small_vector<cpu_pin, 32>& parse_pins()
262263
{
263264
static const auto p = [] {
264-
ossia::small_vector<cpu_pin, 128> vec;
265+
ossia::small_vector<cpu_pin, 32> vec;
265266
auto pins = getenv("SCORE_THREAD_PINS");
266267
if(!pins)
267268
return vec;
@@ -300,6 +301,12 @@ static const ossia::small_vector<cpu_pin, 128>& parse_pins()
300301
case 'u':
301302
core.UiTask = 1;
302303
break;
304+
case 'R':
305+
core.Render = 1;
306+
break;
307+
case 'r':
308+
core.RenderTask = 1;
309+
break;
303310
}
304311
}
305312
vec.push_back(core);
@@ -351,6 +358,11 @@ void ensure_current_thread_kind(thread_type kind)
351358
&& (g_current_thread_type == thread_type::Ui
352359
|| g_current_thread_type == thread_type::UiTask))
353360
return;
361+
else if(
362+
(kind == thread_type::Render || kind == thread_type::RenderTask)
363+
&& (g_current_thread_type == thread_type::Render
364+
|| g_current_thread_type == thread_type::RenderTask))
365+
return;
354366
else
355367
{
356368
fprintf(
@@ -414,6 +426,12 @@ void set_thread_pinned(thread_type spec, int thread_index)
414426
case 'u':
415427
try_pin(core.UiTask);
416428
break;
429+
case 'R':
430+
try_pin(core.Render);
431+
break;
432+
case 'r':
433+
try_pin(core.RenderTask);
434+
break;
417435
}
418436
#undef try_pin
419437
}
@@ -445,6 +463,11 @@ const thread_specs& get_thread_specs() noexcept
445463
map[thread_type::Ui].num_threads = 1;
446464
if(map[thread_type::UiTask].num_threads == 0)
447465
map[thread_type::UiTask].num_threads = 1;
466+
467+
if(map[thread_type::Render].num_threads == 0)
468+
map[thread_type::Render].num_threads = 1;
469+
if(map[thread_type::RenderTask].num_threads == 0)
470+
map[thread_type::RenderTask].num_threads = 1;
448471
};
449472
if(!pins)
450473
{
@@ -484,6 +507,12 @@ const thread_specs& get_thread_specs() noexcept
484507
case 'u':
485508
map[thread_type::UiTask].num_threads++;
486509
break;
510+
case 'R':
511+
map[thread_type::Render].num_threads++;
512+
break;
513+
case 'r':
514+
map[thread_type::RenderTask].num_threads++;
515+
break;
487516
}
488517
}
489518

@@ -531,6 +560,12 @@ const thread_specs& get_thread_specs() noexcept
531560
case 'u':
532561
cur = thread_type::UiTask;
533562
break;
563+
case 'R':
564+
cur = thread_type::Render;
565+
break;
566+
case 'r':
567+
cur = thread_type::RenderTask;
568+
break;
534569
default:
535570
cur_num += c;
536571
break;

src/ossia/detail/thread.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ enum class thread_type : unsigned char
2626
Audio = 'A',
2727
AudioTask = 'a',
2828
Ui = 'U',
29-
UiTask = 'u'
29+
UiTask = 'u',
30+
Render = 'R',
31+
RenderTask = 'r',
3032
};
3133

3234
struct thread_spec

0 commit comments

Comments
 (0)