1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "mojo/public/utility/thread.h"
18 Thread::Thread(const Options& options)
26 // If it was started, it must have been joined.
27 assert(!started_ || joined_);
30 void Thread::Start() {
35 int rv MOJO_ALLOW_UNUSED = pthread_attr_init(&attr);
38 // Non-default stack size?
39 if (options_.stack_size() != 0) {
40 rv = pthread_attr_setstacksize(&attr, options_.stack_size());
45 rv = pthread_create(&thread_, &attr, &ThreadRunTrampoline, this);
48 rv = pthread_attr_destroy(&attr);
53 // Must have been started but not yet joined.
58 int rv MOJO_ALLOW_UNUSED = pthread_join(thread_, NULL);
63 void* Thread::ThreadRunTrampoline(void* arg) {
64 Thread* self = static_cast<Thread*>(arg);