blob: 3e1020275c1f3961b125a5644fcb64120c891006 [file] [log] [blame]
bungeman@google.com55487522012-05-14 14:09:24 +00001/*
2 * Copyright 2012 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 SkThreadUtils_PThreadData_DEFINED
9#define SkThreadUtils_PThreadData_DEFINED
10
11#include "SkThreadUtils.h"
12#include <pthread.h>
13
bungeman@google.com59bc8d42012-05-14 15:40:05 +000014class PThreadEvent : SkNoncopyable {
15public:
16 PThreadEvent();
17 ~PThreadEvent();
18 void trigger();
19 void wait();
20 bool isTriggered();
21
22private:
23 pthread_cond_t fCondition;
24 pthread_mutex_t fConditionMutex;
25 bool fConditionFlag;
26};
27
28class SkThread_PThreadData : SkNoncopyable {
bungeman@google.com55487522012-05-14 14:09:24 +000029public:
30 SkThread_PThreadData(SkThread::entryPointProc entryPoint, void* data);
31 ~SkThread_PThreadData();
32 pthread_t fPThread;
33 bool fValidPThread;
bungeman@google.com59bc8d42012-05-14 15:40:05 +000034 PThreadEvent fStarted;
35 PThreadEvent fCanceled;
36
bungeman@google.com55487522012-05-14 14:09:24 +000037 pthread_attr_t fAttr;
38
39 void* fParam;
40 SkThread::entryPointProc fEntryPoint;
bungeman@google.com55487522012-05-14 14:09:24 +000041};
42
43#endif