Skia
2D Graphics Library
SkExecutor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkExecutor_DEFINED
9 #define SkExecutor_DEFINED
10 
11 #include <functional>
12 #include <memory>
13 #include "include/core/SkTypes.h"
14 
16 public:
17  virtual ~SkExecutor();
18 
19  // Create a thread pool SkExecutor with a fixed thread count, by default the number of cores.
20  static std::unique_ptr<SkExecutor> MakeFIFOThreadPool(int threads = 0,
21  bool allowBorrowing = true);
22  static std::unique_ptr<SkExecutor> MakeLIFOThreadPool(int threads = 0,
23  bool allowBorrowing = true);
24 
25  // There is always a default SkExecutor available by calling SkExecutor::GetDefault().
27  static void SetDefault(SkExecutor*); // Does not take ownership. Not thread safe.
28 
29  // Add work to execute.
30  virtual void add(std::function<void(void)>) = 0;
31 
32  // If it makes sense for this executor, use this thread to execute work for a little while.
33  virtual void borrow() {}
34 
35 protected:
36  SkExecutor() = default;
37  SkExecutor(const SkExecutor&) = delete;
38  SkExecutor& operator=(const SkExecutor&) = delete;
39 };
40 
41 #endif//SkExecutor_DEFINED
SkExecutor::SkExecutor
SkExecutor()=default
SkTypes.h
SkExecutor::operator=
SkExecutor & operator=(const SkExecutor &)=delete
SkExecutor::borrow
virtual void borrow()
Definition: SkExecutor.h:33
SkExecutor::MakeLIFOThreadPool
static std::unique_ptr< SkExecutor > MakeLIFOThreadPool(int threads=0, bool allowBorrowing=true)
SkExecutor::add
virtual void add(std::function< void(void)>)=0
SK_API
#define SK_API
Definition: SkTypes.h:181
SkExecutor::MakeFIFOThreadPool
static std::unique_ptr< SkExecutor > MakeFIFOThreadPool(int threads=0, bool allowBorrowing=true)
SkExecutor::~SkExecutor
virtual ~SkExecutor()
SkExecutor::SkExecutor
SkExecutor(const SkExecutor &)=delete
SkExecutor::GetDefault
static SkExecutor & GetDefault()
SkExecutor::SetDefault
static void SetDefault(SkExecutor *)
SkExecutor
Definition: SkExecutor.h:15