Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
dart::CheckinTask Class Reference
Inheritance diagram for dart::CheckinTask:
dart::StateMachineTask dart::ThreadPool::Task dart::IntrusiveDListEntry< Task >

Classes

struct  Data
 

Public Types

enum  State { kStartLoop = StateMachineTask::kNext }
 
- Public Types inherited from dart::StateMachineTask
enum  State {
  kInitialized = 0 , kEntered , kPleaseExit , kExited ,
  kNext
}
 

Public Member Functions

 CheckinTask (std::shared_ptr< Data > data)
 
- Public Member Functions inherited from dart::StateMachineTask
 StateMachineTask (std::shared_ptr< Data > data)
 
virtual void Run ()
 
- Public Member Functions inherited from dart::ThreadPool::Task
virtual ~Task ()
 
virtual void Run ()=0
 
- Public Member Functions inherited from dart::IntrusiveDListEntry< Task >
 IntrusiveDListEntry ()
 
 ~IntrusiveDListEntry ()
 

Protected Member Functions

Datadata ()
 
virtual void RunInternal ()
 
bool SafepointIfRequested (Thread *thread, std::atomic< intptr_t > *checkins)
 
virtual void RunInternal ()=0
 
- Protected Member Functions inherited from dart::ThreadPool::Task
 Task ()
 

Additional Inherited Members

- Protected Attributes inherited from dart::StateMachineTask
std::shared_ptr< Datadata_
 
Threadthread_ = nullptr
 

Detailed Description

Definition at line 293 of file safepoint_test.cc.

Member Enumeration Documentation

◆ State

Enumerator
kStartLoop 

Definition at line 295 of file safepoint_test.cc.

Constructor & Destructor Documentation

◆ CheckinTask()

dart::CheckinTask::CheckinTask ( std::shared_ptr< Data data)
inlineexplicit

Definition at line 320 of file safepoint_test.cc.

StateMachineTask(std::shared_ptr< Data > data)

Member Function Documentation

◆ data()

Data * dart::CheckinTask::data ( )
inlineprotected

Definition at line 323 of file safepoint_test.cc.

323{ return reinterpret_cast<Data*>(data_.get()); }
std::shared_ptr< Data > data_
struct PathData * Data(SkPath *path)
Definition: path_ops.cc:52

◆ RunInternal()

virtual void dart::CheckinTask::RunInternal ( )
inlineprotectedvirtual

Implements dart::StateMachineTask.

Definition at line 325 of file safepoint_test.cc.

325 {
326 data_->WaitUntil(kStartLoop);
327
328 uword last_sync = OS::GetCurrentTimeMillis();
329 while (!data()->IsIn(kPleaseExit)) {
330 OS::SleepMicros(100); // Make test avoid consuming 100% CPU x kTaskCount.
331 switch (data()->level) {
332 case SafepointLevel::kGC: {
333 // This thread should join only GC safepoint operations.
334 RuntimeCallDeoptScope no_deopt(
336 if (SafepointIfRequested(thread_, data()->gc_only_checkins)) {
337 last_sync = OS::GetCurrentTimeMillis();
338 }
339 break;
340 }
342 // This thread should join only GC and Deopt safepoint operations.
343 if (SafepointIfRequested(thread_, data()->deopt_checkin)) {
344 last_sync = OS::GetCurrentTimeMillis();
345 }
346 break;
347 }
349 // This thread should join any safepoint operations.
350 ReloadParticipationScope allow_reload(thread_);
351 if (SafepointIfRequested(thread_, data()->reload_checkin)) {
352 last_sync = OS::GetCurrentTimeMillis();
353 }
354 break;
355 }
358 UNREACHABLE();
359 }
360
361 // If the main thread asks us to join a deopt safepoint but we are
362 // instructed to only really collaborate with GC safepoints we won't
363 // participate in the above cases (and therefore not register our
364 // check-in by increasing the checkin counts).
365 //
366 // After being quite sure to not have joined deopt safepoint if we only
367 // support GC safepoints, we will eventually comply here to make main
368 // thread continue.
369 const auto now = OS::GetCurrentTimeMillis();
370 if ((now - last_sync) > 1000) {
371 ReloadParticipationScope allow_reload(thread_);
372 if (SafepointIfRequested(thread_, data()->timeout_checkin)) {
373 last_sync = now;
374 }
375 }
376 }
377 }
#define UNREACHABLE()
Definition: assert.h:248
bool SafepointIfRequested(Thread *thread, std::atomic< intptr_t > *checkins)
static void SleepMicros(int64_t micros)
static int64_t GetCurrentTimeMillis()
static Thread * Current()
Definition: thread.h:362
@ kGC
Definition: thread.h:291
@ kNumLevels
Definition: thread.h:297
@ kNoSafepoint
Definition: thread.h:300
@ kGCAndDeoptAndReload
Definition: thread.h:295
@ kGCAndDeopt
Definition: thread.h:293
uintptr_t uword
Definition: globals.h:501
AsThreadStackResource< RawReloadParticipationScope > ReloadParticipationScope
Definition: thread.h:1634

◆ SafepointIfRequested()

bool dart::CheckinTask::SafepointIfRequested ( Thread thread,
std::atomic< intptr_t > *  checkins 
)
inlineprotected

Definition at line 379 of file safepoint_test.cc.

379 {
380 if (thread->IsSafepointRequested()) {
381 // Collaborates by checking into the safepoint.
382 thread->BlockForSafepoint();
383 (*checkins)++;
384 return true;
385 }
386 return false;
387 }

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