Lines Matching defs:thread
22 // Trivial tests that thread runs and doesn't crash on create, join, or detach -
44 TrivialThread thread;
47 ASSERT_FALSE(thread.run_event().IsSignaled());
48 ASSERT_TRUE(PlatformThread::Create(0, &thread, &handle));
50 ASSERT_TRUE(thread.run_event().IsSignaled());
54 TrivialThread thread[10];
55 PlatformThreadHandle handle[arraysize(thread)];
57 for (size_t n = 0; n < arraysize(thread); n++)
58 ASSERT_FALSE(thread[n].run_event().IsSignaled());
59 for (size_t n = 0; n < arraysize(thread); n++)
60 ASSERT_TRUE(PlatformThread::Create(0, &thread[n], &handle[n]));
61 for (size_t n = 0; n < arraysize(thread); n++)
63 for (size_t n = 0; n < arraysize(thread); n++)
64 ASSERT_TRUE(thread[n].run_event().IsSignaled());
68 // end and termination of the thread, but threads could persist shortly after
71 TrivialThread thread;
74 ASSERT_FALSE(thread.run_event().IsSignaled());
75 ASSERT_TRUE(PlatformThread::Create(0, &thread, &handle));
77 thread.run_event().Wait();
81 TrivialThread thread[10];
82 PlatformThreadHandle handle[arraysize(thread)];
84 for (size_t n = 0; n < arraysize(thread); n++)
85 ASSERT_FALSE(thread[n].run_event().IsSignaled());
86 for (size_t n = 0; n < arraysize(thread); n++) {
87 ASSERT_TRUE(PlatformThread::Create(0, &thread[n], &handle[n]));
90 for (size_t n = 0; n < arraysize(thread); n++)
91 thread[n].run_event().Wait();
94 // Tests of basic thread functions ---------------------------------------------
109 << "Need to mark thread for termination and join the underlying thread "
111 << "WaitableEvent blocking the underlying thread's main.";
114 // Grabs |thread_id_|, runs an optional test on that thread, signals
121 // Make sure that the thread ID is the same across calls.
134 EXPECT_TRUE(termination_ready_.IsSignaled()) << "Thread ID still unknown";
142 // Blocks until this thread is started and ready to be terminated.
145 // Marks this thread for termination (callers must then join this thread to be
150 // Runs an optional test on the newly created thread.
167 FunctionTestThread thread;
170 ASSERT_FALSE(thread.IsRunning());
171 ASSERT_TRUE(PlatformThread::Create(0, &thread, &handle));
172 thread.WaitForTerminationReady();
173 ASSERT_TRUE(thread.IsRunning());
174 EXPECT_NE(thread.thread_id(), main_thread_id);
176 thread.MarkForTermination();
178 ASSERT_FALSE(thread.IsRunning());
180 // Make sure that the thread ID is the same across calls.
187 FunctionTestThread thread[10];
188 PlatformThreadHandle handle[arraysize(thread)];
190 for (size_t n = 0; n < arraysize(thread); n++)
191 ASSERT_FALSE(thread[n].IsRunning());
193 for (size_t n = 0; n < arraysize(thread); n++)
194 ASSERT_TRUE(PlatformThread::Create(0, &thread[n], &handle[n]));
195 for (size_t n = 0; n < arraysize(thread); n++)
196 thread[n].WaitForTerminationReady();
198 for (size_t n = 0; n < arraysize(thread); n++) {
199 ASSERT_TRUE(thread[n].IsRunning());
200 EXPECT_NE(thread[n].thread_id(), main_thread_id);
204 EXPECT_NE(thread[i].thread_id(), thread[n].thread_id());
208 for (size_t n = 0; n < arraysize(thread); n++)
209 thread[n].MarkForTermination();
210 for (size_t n = 0; n < arraysize(thread); n++)
212 for (size_t n = 0; n < arraysize(thread); n++)
213 ASSERT_FALSE(thread[n].IsRunning());
215 // Make sure that the thread ID is the same across calls.
244 // Confirm that the current thread's priority is as expected.
248 // Alter and verify the current thread's priority.
260 // Test changing a created thread's priority (which has different semantics on
263 // TODO(crbug.com/851759): Thread priorities are not implemented in Fuchsia.
274 // priority of the main thread. Also skip this on platforms that don't allow
275 // increasing the priority of a thread.
281 // Toggle each supported priority on the thread and confirm it affects it.
289 ThreadPriorityTestThread thread(kThreadPriorityTestValues[i]);
292 ASSERT_FALSE(thread.IsRunning());
293 ASSERT_TRUE(PlatformThread::Create(0, &thread, &handle));
294 thread.WaitForTerminationReady();
295 ASSERT_TRUE(thread.IsRunning());
297 thread.MarkForTermination();
299 ASSERT_FALSE(thread.IsRunning());
365 // Construct an excessively long thread name.