180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2012 Google Inc. 380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * 480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file. 680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkThreadUtils_PThreadData_DEFINED 980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkThreadUtils_PThreadData_DEFINED 1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkThreadUtils.h" 1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include <pthread.h> 1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass PThreadEvent : SkNoncopyable { 1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru PThreadEvent(); 1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru ~PThreadEvent(); 1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void trigger(); 1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void wait(); 2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool isTriggered(); 2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru pthread_cond_t fCondition; 2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru pthread_mutex_t fConditionMutex; 2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool fConditionFlag; 2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkThread_PThreadData : SkNoncopyable { 2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkThread_PThreadData(SkThread::entryPointProc entryPoint, void* data); 3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru ~SkThread_PThreadData(); 3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru pthread_t fPThread; 3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool fValidPThread; 3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru PThreadEvent fStarted; 3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru PThreadEvent fCanceled; 3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru pthread_attr_t fAttr; 3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void* fParam; 4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkThread::entryPointProc fEntryPoint; 4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 44