The spica renderer
parallel.h
1 #ifdef _MSC_VER
2 #pragma once
3 #endif
4 
5 #ifndef _SPICA_PARALLEL_H_
6 #define _SPICA_PARALLEL_H_
7 
8 #include <iostream>
9 #include <atomic>
10 #include <functional>
11 
12 #include "core/common.h"
13 
14 namespace spica {
15 
16 class SPICA_EXPORTS AtomicDouble {
17 public:
18  explicit AtomicDouble(double v = 0.0);
19  explicit operator double() const;
20  double operator=(double v);
21  void add(double v);
22 
23 private:
24  std::atomic<uint64_t> bits;
25 };
26 
27 } // namespace spica
28 
29 enum class ParallelSchedule {
30  Static = 0x01,
31  Dynamic = 0x02
32 };
33 
34 SPICA_EXPORTS void parallel_for(int start, int end, const std::function<void(int)>& func,
35  ParallelSchedule schedule = ParallelSchedule::Dynamic);
36 
37 SPICA_EXPORTS int numSystemThreads();
38 SPICA_EXPORTS int getThreadID();
39 SPICA_EXPORTS void setNumThreads(uint32_t n);
40 
41 #endif // _SPICA_PARALLEL_H_
Definition: parallel.h:16