| Index: base/threading/simple_thread.h
|
| diff --git a/base/threading/simple_thread.h b/base/threading/simple_thread.h
|
| index dd1fc6c18e6d4f250e2757e1e0adbabade1ec6ff..3deeb1018cb573c3f5e48d2b17b7c16a428aa476 100644
|
| --- a/base/threading/simple_thread.h
|
| +++ b/base/threading/simple_thread.h
|
| @@ -48,7 +48,6 @@
|
|
|
| #include "base/base_export.h"
|
| #include "base/compiler_specific.h"
|
| -#include "base/macros.h"
|
| #include "base/synchronization/lock.h"
|
| #include "base/synchronization/waitable_event.h"
|
| #include "base/threading/platform_thread.h"
|
| @@ -59,25 +58,25 @@
|
| // virtual Run method, or you can use the DelegateSimpleThread interface.
|
| class BASE_EXPORT SimpleThread : public PlatformThread::Delegate {
|
| public:
|
| - struct BASE_EXPORT Options {
|
| + class BASE_EXPORT Options {
|
| public:
|
| - Options() = default;
|
| - explicit Options(ThreadPriority priority_in) : priority(priority_in) {}
|
| - ~Options() = default;
|
| + Options() : stack_size_(0), priority_(ThreadPriority::NORMAL) {}
|
| + explicit Options(ThreadPriority priority)
|
| + : stack_size_(0), priority_(priority) {}
|
| + ~Options() {}
|
|
|
| - // Allow copies.
|
| - Options(const Options& other) = default;
|
| - Options& operator=(const Options& other) = default;
|
| + // We use the standard compiler-supplied copy constructor.
|
|
|
| // A custom stack size, or 0 for the system default.
|
| - size_t stack_size = 0;
|
| + void set_stack_size(size_t size) { stack_size_ = size; }
|
| + size_t stack_size() const { return stack_size_; }
|
|
|
| - ThreadPriority priority = ThreadPriority::NORMAL;
|
| -
|
| - // If false, the thread's PlatformThreadHandle will not be kept around and
|
| - // the SimpleThread instance will not be required to be Join()'ed before
|
| - // being destroyed
|
| - bool joinable = true;
|
| + // A custom thread priority.
|
| + void set_priority(ThreadPriority priority) { priority_ = priority; }
|
| + ThreadPriority priority() const { return priority_; }
|
| + private:
|
| + size_t stack_size_;
|
| + ThreadPriority priority_;
|
| };
|
|
|
| // Create a SimpleThread. |options| should be used to manage any specific
|
| @@ -107,7 +106,7 @@
|
| // Return True if Start() has ever been called.
|
| bool HasBeenStarted();
|
|
|
| - // Return True if Join() has ever been called.
|
| + // Return True if Join() has evern been called.
|
| bool HasBeenJoined() { return joined_; }
|
|
|
| // Overridden from PlatformThread::Delegate:
|
| @@ -117,12 +116,10 @@
|
| const std::string name_prefix_;
|
| std::string name_;
|
| const Options options_;
|
| - PlatformThreadHandle thread_; // PlatformThread handle, reset after Join.
|
| + PlatformThreadHandle thread_; // PlatformThread handle, invalid after Join!
|
| WaitableEvent event_; // Signaled if Start() was ever called.
|
| - PlatformThreadId tid_ = kInvalidThreadId; // The backing thread's id.
|
| - bool joined_ = false; // True if Join has been called.
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(SimpleThread);
|
| + PlatformThreadId tid_; // The backing thread's id.
|
| + bool joined_; // True if Join has been called.
|
| };
|
|
|
| class BASE_EXPORT DelegateSimpleThread : public SimpleThread {
|
| @@ -145,8 +142,6 @@
|
|
|
| private:
|
| Delegate* delegate_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(DelegateSimpleThread);
|
| };
|
|
|
| // DelegateSimpleThreadPool allows you to start up a fixed number of threads,
|
| @@ -191,8 +186,6 @@
|
| std::queue<Delegate*> delegates_;
|
| base::Lock lock_; // Locks delegates_
|
| WaitableEvent dry_; // Not signaled when there is no work to do.
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(DelegateSimpleThreadPool);
|
| };
|
|
|
| } // namespace base
|
|
|