| 1562 | } |
| 1563 | |
| 1564 | void threads_create_join(uint64_t n, |
| 1565 | thread_entry start, void* arg, uint64_t stack_size) |
| 1566 | { |
| 1567 | if (n == 0) return; |
| 1568 | thread* threads[32]; |
| 1569 | thread** pthreads = threads; |
| 1570 | std::vector<thread*> _threads; |
| 1571 | if (n > 32) |
| 1572 | { |
| 1573 | _threads.resize(n); |
| 1574 | pthreads = &_threads[0]; |
| 1575 | } |
| 1576 | for (uint64_t i = 0; i < n; ++i) |
| 1577 | { |
| 1578 | auto th = thread_create(start, arg, stack_size); |
| 1579 | if (!th) break; |
| 1580 | thread_enable_join(th); |
| 1581 | pthreads[i] = th; |
| 1582 | } |
| 1583 | for (uint64_t i = 0; i < n; ++i) { |
| 1584 | thread_join(pthreads[i]); |
| 1585 | } |
| 1586 | } |
| 1587 | |
| 1588 | void Timer::stub() |
| 1589 | { |