| 52 | |
| 53 | QTimer m_deadline; |
| 54 | void run() override |
| 55 | { |
| 56 | BigConcurrentTask big_task; |
| 57 | m_deadline.setInterval(10000); |
| 58 | |
| 59 | // NOTE: Arbitrary value that manages to trigger a problem when there is one. |
| 60 | // Considering each tasks, in a problematic state, adds 1024 * 4 bytes to the stack, |
| 61 | // this number is enough to fill up 16 MiB of stack, more than enough to cause a problem. |
| 62 | static const unsigned s_num_tasks = 1 << 12; |
| 63 | for (unsigned i = 0; i < s_num_tasks; i++) { |
| 64 | auto sub_task = makeShared<BasicTask>(false); |
| 65 | big_task.addTask(sub_task); |
| 66 | } |
| 67 | |
| 68 | connect(&big_task, &Task::finished, this, &QThread::quit); |
| 69 | connect(&m_deadline, &QTimer::timeout, this, [&] { |
| 70 | passed_the_deadline = true; |
| 71 | quit(); |
| 72 | }); |
| 73 | |
| 74 | if (thread() != QThread::currentThread()) { |
| 75 | QMetaObject::invokeMethod(this, &BigConcurrentTaskThread::start_timer, Qt::QueuedConnection); |
| 76 | } |
| 77 | big_task.run(); |
| 78 | |
| 79 | exec(); |
| 80 | } |
| 81 | void start_timer() { m_deadline.start(); } |
| 82 | |
| 83 | public: |