aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkThreadUtils.h
blob: b0c5044618837fbba2362f298c32292f42cd0673 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkThreadUtils_DEFINED
#define SkThreadUtils_DEFINED

#include "SkTypes.h"

class SkThread : SkNoncopyable {
public:
    typedef void (*entryPointProc)(void*);
    
    SkThread(entryPointProc entryPoint, void* data = NULL);
    
    /**
     * Non-virtual, do not subclass.
     */
    ~SkThread();
    
    /**
     * Starts the thread. Returns false if the thread could not be started.
     */
    bool start();
    
    /**
     * Waits for the thread to finish.
     * If the thread has not started, returns immediately.
     */
    void join();
    
    /**
     * SkThreads with an affinity for the same processor will attempt to run cache
     * locally with each other. SkThreads with an affinity for different processors
     * will attempt to run on different cores. Returns false if the request failed.
     */
    bool setProcessorAffinity(unsigned int processor);
    
private:
    void* fData;
};

#endif