DeviceDescriptor: eliminate obsolete NMEAOut kludge
[xcsoar.git] / src / DrawThread.hpp
blob7142ba23cc2c3cee6245284e3b20db05e9b5fce1
1 /*
2 Copyright_License {
4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_DRAW_THREAD_HPP
25 #define XCSOAR_DRAW_THREAD_HPP
27 #include "Thread/RecursivelySuspensibleThread.hpp"
28 #include "Thread/Trigger.hpp"
30 class GlueMapWindow;
32 /**
33 * The DrawThread handles the rendering and drawing on the screen.
34 * The Map and GaugeFLARM both are triggered on GPS updates synchronously,
35 * which is why they are both handled by this thread. The GaugeVario is
36 * triggered on vario data which may be faster than GPS updates, which is
37 * why it is not handled by this thread.
40 class DrawThread : public RecursivelySuspensibleThread {
41 enum {
42 MIN_WAIT_TIME = 100,
45 /**
46 * This triggers a redraw.
48 Trigger trigger;
50 /** Pointer to the MapWindow */
51 GlueMapWindow ↦
53 public:
54 DrawThread(GlueMapWindow &_map)
55 :map(_map) {}
57 /** Locks the Mutex and "pauses" the drawing thread */
58 void BeginSuspend() {
59 RecursivelySuspensibleThread::BeginSuspend();
60 TriggerRedraw();
63 void Suspend() {
64 BeginSuspend();
65 WaitUntilSuspended();
68 /**
69 * To be removed, only used by GlueMapWindow::Idle().
71 bool IsTriggered() {
72 return trigger.Test();
75 /**
76 * Triggers a redraw.
78 void TriggerRedraw() {
79 trigger.Signal();
82 /**
83 * Triggers thread shutdown. Call join() after this to wait
84 * synchronously for the thread to exit.
86 void BeginStop() {
87 RecursivelySuspensibleThread::BeginStop();
88 TriggerRedraw();
91 protected:
92 virtual void Run();
95 #endif