OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::IdleScheduler Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/IdleScheduler.hpp>

Collaboration diagram for Slic3r::GUI::IdleScheduler:

Public Member Functions

 IdleScheduler (std::function< int()> input_idle_ms)
void add (LazyBase &task)
void clear ()
std::string names () const
void start ()
void stop ()

Private Member Functions

void tick ()

Private Attributes

PrebuildQueue m_queue
wxTimer m_timer
std::function< int()> m_input_idle_ms
bool m_in_slice { false }

Detailed Description

Constructor & Destructor Documentation

◆ IdleScheduler()

Slic3r::GUI::IdleScheduler::IdleScheduler ( std::function< int()> input_idle_ms)
explicit
57 : m_input_idle_ms(std::move(input_idle_ms))
58{
59 m_timer.Bind(wxEVT_TIMER, [this](wxTimerEvent&) { tick(); });
60}
wxTimer m_timer
Definition IdleScheduler.hpp:38
std::function< int()> m_input_idle_ms
Definition IdleScheduler.hpp:39
void tick()
Definition IdleScheduler.cpp:73

References m_input_idle_ms, m_timer, and tick().

Here is the call graph for this function:

Member Function Documentation

◆ add()

void Slic3r::GUI::IdleScheduler::add ( LazyBase & task)
inline
24{ m_queue.add(task); }
PrebuildQueue m_queue
Definition IdleScheduler.hpp:37

References m_queue.

◆ clear()

void Slic3r::GUI::IdleScheduler::clear ( )
inline
25{ m_queue.clear(); }

References m_queue.

◆ names()

std::string Slic3r::GUI::IdleScheduler::names ( ) const
inline
27{ return m_queue.names(); }

References m_queue.

◆ start()

void Slic3r::GUI::IdleScheduler::start ( )
63{
64 if (!m_timer.IsRunning())
65 m_timer.Start(tick_ms);
66}

References m_timer.

Referenced by tick().

Here is the caller graph for this function:

◆ stop()

void Slic3r::GUI::IdleScheduler::stop ( )
69{
70 m_timer.Stop();
71}

References m_timer.

Referenced by tick().

Here is the caller graph for this function:

◆ tick()

void Slic3r::GUI::IdleScheduler::tick ( )
private
74{
75 // A unit that pumps the event loop lets the timer fire inside its own slice.
76 if (m_in_slice)
77 return;
78 if (!m_queue.pending()) {
79 stop();
80 return;
81 }
82 if (m_input_idle_ms() < quiet_ms || input_pending() || yielding()) {
83 start();
84 return;
85 }
86 const auto now_ms = [] {
87 return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
88 };
89 const char* const fn = __FUNCTION__;
90 m_in_slice = true;
91 PrebuildQueue::Slice slice;
92 {
93 ScopeGuard in_slice([this] { m_in_slice = false; });
94 slice = m_queue.run_slice(slice_ms, now_ms, input_pending, [fn](const std::string& name, long long ms) {
95 BOOST_LOG_TRIVIAL(debug) << fn << ": " << name << ": unit took " << ms << " ms";
96 });
97 }
98 if (slice.completed)
99 BOOST_LOG_TRIVIAL(info) << fn << ": task complete: " << slice.name << ", " << slice.units << " unit(s) in " << slice.ms << " ms this slice";
100 else
101 BOOST_LOG_TRIVIAL(debug) << fn << ": " << slice.name << ": " << slice.units << " unit(s) in " << slice.ms << " ms, yielding";
102 if (!slice.remaining)
103 stop();
104 else if (input_pending())
105 m_timer.Start(tick_ms);
106 else
107 m_timer.StartOnce(next_slice_ms);
108}
void start()
Definition IdleScheduler.cpp:62
void stop()
Definition IdleScheduler.cpp:68
bool m_in_slice
Definition IdleScheduler.hpp:40
bool input_pending()
Definition IdleScheduler.cpp:37
bool yielding()
Definition IdleScheduler.cpp:49

References Slic3r::GUI::PrebuildQueue::Slice::completed, m_in_slice, m_input_idle_ms, m_queue, m_timer, Slic3r::GUI::PrebuildQueue::Slice::ms, Slic3r::GUI::PrebuildQueue::Slice::name, Slic3r::GUI::PrebuildQueue::Slice::remaining, start(), stop(), and Slic3r::GUI::PrebuildQueue::Slice::units.

Referenced by IdleScheduler().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_in_slice

bool Slic3r::GUI::IdleScheduler::m_in_slice { false }
private
40{ false };

Referenced by tick().

◆ m_input_idle_ms

std::function<int()> Slic3r::GUI::IdleScheduler::m_input_idle_ms
private

Referenced by IdleScheduler(), and tick().

◆ m_queue

PrebuildQueue Slic3r::GUI::IdleScheduler::m_queue
private

Referenced by add(), clear(), names(), and tick().

◆ m_timer

wxTimer Slic3r::GUI::IdleScheduler::m_timer
private

Referenced by IdleScheduler(), start(), stop(), and tick().


The documentation for this class was generated from the following files: