Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 ()
 
- 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)
 
- 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 291 of file safepoint_test.cc.

Member Enumeration Documentation

◆ State

Enumerator
kStartLoop 

Definition at line 293 of file safepoint_test.cc.

Constructor & Destructor Documentation

◆ CheckinTask()

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

Definition at line 318 of file safepoint_test.cc.

StateMachineTask(std::shared_ptr< Data > data)

Member Function Documentation

◆ data()

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

Definition at line 321 of file safepoint_test.cc.

321{ 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 323 of file safepoint_test.cc.

323 {
324 data_->WaitUntil(kStartLoop);
325
326 uword last_sync = OS::GetCurrentTimeMillis();
327 while (!data()->IsIn(kPleaseExit)) {
328 OS::SleepMicros(100); // Make test avoid consuming 100% CPU x kTaskCount.
329 switch (data()->level) {
330 case SafepointLevel::kGC: {
331 // This thread should join only GC safepoint operations.
332 RuntimeCallDeoptScope no_deopt(
334 if (SafepointIfRequested(thread_, data()->gc_only_checkins)) {
335 last_sync = OS::GetCurrentTimeMillis();
336 }
337 break;
338 }
340 // This thread should join only GC and Deopt safepoint operations.
341 if (SafepointIfRequested(thread_, data()->deopt_checkin)) {
342 last_sync = OS::GetCurrentTimeMillis();
343 }
344 break;
345 }
347 // This thread should join any safepoint operations.
348 ReloadParticipationScope allow_reload(thread_);
349 if (SafepointIfRequested(thread_, data()->reload_checkin)) {
350 last_sync = OS::GetCurrentTimeMillis();
351 }
352 break;
353 }
356 UNREACHABLE();
357 }
358
359 // If the main thread asks us to join a deopt safepoint but we are
360 // instructed to only really collaborate with GC safepoints we won't
361 // participate in the above cases (and therefore not register our
362 // check-in by increasing the checkin counts).
363 //
364 // After being quite sure to not have joined deopt safepoint if we only
365 // support GC safepoints, we will eventually comply here to make main
366 // thread continue.
367 const auto now = OS::GetCurrentTimeMillis();
368 if ((now - last_sync) > 1000) {
369 ReloadParticipationScope allow_reload(thread_);
370 if (SafepointIfRequested(thread_, data()->timeout_checkin)) {
371 last_sync = now;
372 }
373 }
374 }
375 }
#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:361
@ 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:1612

◆ SafepointIfRequested()

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

Definition at line 377 of file safepoint_test.cc.

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

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