michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkThreadUtils_DEFINED michael@0: #define SkThreadUtils_DEFINED michael@0: michael@0: #include "SkTypes.h" michael@0: michael@0: class SkThread : SkNoncopyable { michael@0: public: michael@0: typedef void (*entryPointProc)(void*); michael@0: michael@0: SkThread(entryPointProc entryPoint, void* data = NULL); michael@0: michael@0: /** michael@0: * Non-virtual, do not subclass. michael@0: */ michael@0: ~SkThread(); michael@0: michael@0: /** michael@0: * Starts the thread. Returns false if the thread could not be started. michael@0: */ michael@0: bool start(); michael@0: michael@0: /** michael@0: * Waits for the thread to finish. michael@0: * If the thread has not started, returns immediately. michael@0: */ michael@0: void join(); michael@0: michael@0: /** michael@0: * SkThreads with an affinity for the same processor will attempt to run cache michael@0: * locally with each other. SkThreads with an affinity for different processors michael@0: * will attempt to run on different cores. Returns false if the request failed. michael@0: */ michael@0: bool setProcessorAffinity(unsigned int processor); michael@0: michael@0: private: michael@0: void* fData; michael@0: }; michael@0: michael@0: #endif