Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::InfiniteLoopTask Class Reference
Inheritance diagram for dart::InfiniteLoopTask:
dart::ThreadPool::Task dart::IntrusiveDListEntry< Task >

Public Member Functions

 InfiniteLoopTask (Dart_Isolate *isolate, Monitor *monitor, bool *interrupted)
 
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 ()
 

Additional Inherited Members

- Protected Member Functions inherited from dart::ThreadPool::Task
 Task ()
 

Detailed Description

Definition at line 157 of file dart_api_impl_test.cc.

Constructor & Destructor Documentation

◆ InfiniteLoopTask()

dart::InfiniteLoopTask::InfiniteLoopTask ( Dart_Isolate isolate,
Monitor monitor,
bool *  interrupted 
)
inline

Definition at line 159 of file dart_api_impl_test.cc.

160 : isolate_(isolate), monitor_(monitor), interrupted_(interrupted) {}

Member Function Documentation

◆ Run()

virtual void dart::InfiniteLoopTask::Run ( )
inlinevirtual

Implements dart::ThreadPool::Task.

Definition at line 161 of file dart_api_impl_test.cc.

161 {
162 TestIsolateScope scope;
163 const char* kScriptChars =
164 "testMain() {\n"
165 " while(true) {};"
166 "}\n";
167 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, nullptr);
168 EXPECT_VALID(lib);
169 *isolate_ = reinterpret_cast<Dart_Isolate>(Isolate::Current());
170 {
171 MonitorLocker ml(monitor_);
172 ml.Notify();
173 }
174 Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, nullptr);
175 // Test should run an infinite loop and expect that to be killed.
177 EXPECT_STREQ("isolate terminated by Isolate.kill", Dart_GetError(result));
178 {
179 MonitorLocker ml(monitor_);
180 *interrupted_ = true;
181 ml.Notify();
182 }
183 }
#define EXPECT(type, expectedAlignment, expectedSize)
static Isolate * Current()
Definition: isolate.h:986
static Dart_Handle LoadTestScript(const char *script, Dart_NativeEntryResolver resolver, const char *lib_uri=RESOLVED_USER_TEST_URI, bool finalize=true, bool allow_compile_errors=false)
Definition: unit_test.cc:436
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
struct _Dart_Isolate * Dart_Isolate
Definition: dart_api.h:88
GAsyncResult * result
DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT const char * Dart_GetError(Dart_Handle handle)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
Dart_Handle NewString(const char *str)
#define EXPECT_VALID(handle)
Definition: unit_test.h:643

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