Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
dart::MutatorThreadPool Class Reference

#include <isolate.h>

Inheritance diagram for dart::MutatorThreadPool:
dart::ThreadPool

Public Member Functions

 MutatorThreadPool (IsolateGroup *isolate_group, intptr_t max_pool_size)
 
virtual ~MutatorThreadPool ()
 
- Public Member Functions inherited from dart::ThreadPool
 ThreadPool (uintptr_t max_pool_size=0)
 
virtual ~ThreadPool ()
 
template<typename T , typename... Args>
bool Run (Args &&... args)
 
bool CurrentThreadIsWorker ()
 
void MarkCurrentWorkerAsBlocked ()
 
void MarkCurrentWorkerAsUnBlocked ()
 
void Shutdown ()
 
uint64_t workers_started () const
 
uint64_t workers_stopped () const
 

Protected Member Functions

virtual void OnEnterIdleLocked (MonitorLocker *ml)
 
- Protected Member Functions inherited from dart::ThreadPool
bool ShuttingDownLocked ()
 
bool TasksWaitingToRunLocked ()
 

Detailed Description

Definition at line 251 of file isolate.h.

Constructor & Destructor Documentation

◆ MutatorThreadPool()

dart::MutatorThreadPool::MutatorThreadPool ( IsolateGroup isolate_group,
intptr_t  max_pool_size 
)
inline

Definition at line 253 of file isolate.h.

254 : ThreadPool(max_pool_size), isolate_group_(isolate_group) {}
ThreadPool(uintptr_t max_pool_size=0)

◆ ~MutatorThreadPool()

virtual dart::MutatorThreadPool::~MutatorThreadPool ( )
inlinevirtual

Definition at line 255 of file isolate.h.

255{}

Member Function Documentation

◆ OnEnterIdleLocked()

void dart::MutatorThreadPool::OnEnterIdleLocked ( MonitorLocker ml)
protectedvirtual

Reimplemented from dart::ThreadPool.

Definition at line 278 of file isolate.cc.

278 {
279 if (FLAG_idle_timeout_micros == 0) return;
280
281 // If the isolate has not started running application code yet, we ignore the
282 // idle time.
283 if (!isolate_group_->initial_spawn_successful()) return;
284
285 int64_t idle_expiry = 0;
286 // Obtain the idle time we should wait.
287 if (isolate_group_->idle_time_handler()->ShouldNotifyIdle(&idle_expiry)) {
288 MonitorLeaveScope mls(ml);
289 NotifyIdle();
290 return;
291 }
292
293 // Avoid shutdown having to wait for the timeout to expire.
294 if (ShuttingDownLocked()) return;
295
296 // Wait for the recommended idle timeout.
297 // We can be woken up because of a), b) or c)
298 const auto result =
299 ml->WaitMicros(idle_expiry - OS::GetCurrentMonotonicMicros());
300
301 // a) If there are new tasks we have to run them.
302 if (TasksWaitingToRunLocked()) return;
303
304 // b) If the thread pool is shutting down we're done.
305 if (ShuttingDownLocked()) return;
306
307 // c) We timed out and should run the idle notifier.
308 if (result == Monitor::kTimedOut &&
309 isolate_group_->idle_time_handler()->ShouldNotifyIdle(&idle_expiry)) {
310 MonitorLeaveScope mls(ml);
311 NotifyIdle();
312 return;
313 }
314
315 // There must've been another thread doing active work in the meantime.
316 // If that thread becomes idle and is the last idle thread it will run this
317 // code again.
318}
bool ShouldNotifyIdle(int64_t *expiry)
Definition isolate.cc:209
bool initial_spawn_successful()
Definition isolate.h:292
IdleTimeHandler * idle_time_handler()
Definition isolate.h:317
static int64_t GetCurrentMonotonicMicros()
bool ShuttingDownLocked()
bool TasksWaitingToRunLocked()
GAsyncResult * result

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