2 * Copyright (C) 2011 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef _LIB_OPENGL_RENDER_RENDER_THREAD_H
18 #define _LIB_OPENGL_RENDER_RENDER_THREAD_H
20 #include "external/android-emugl/host/include/libOpenglRender/IOStream.h"
22 #include "emugl/common/thread.h"
29 // A class used to model a thread of the RenderServer. Each one of them
30 // handles a single guest client / protocol byte stream.
31 class RenderThread : public emugl::Thread {
33 // Create a new RenderThread instance.
34 // |stream| is an input stream that will be read from the thread,
35 // and deleted by it when it exits.
36 // |mutex| is a pointer to a shared mutex used to serialize
37 // decoding operations between all threads.
38 // TODO(digit): Why is this needed here? Shouldn't this be handled
39 // by the decoders themselves or at a lower-level?
40 static RenderThread* create(const std::shared_ptr<Renderer>& renderer, IOStream* stream, std::mutex &m);
43 virtual ~RenderThread();
45 // Returns true iff the thread has finished.
46 // Note that this also means that the thread's stack has been
47 bool isFinished() { return tryWait(NULL); }
49 // Force a thread to stop.
53 RenderThread(); // No default constructor
55 RenderThread(const std::shared_ptr<Renderer>& renderer, IOStream* stream, std::mutex &m);
57 virtual intptr_t main();
59 std::shared_ptr<Renderer> renderer_;