aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkThreadUtils.h
blob: d9fc99d397a6b921ac2e9075b8f00c3309e19e2f (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
/*
 * 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 = nullptr);

    /**
     * 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();

private:
    void* fData;
};

#endif