add a callback to stop() to allow running the current thread's event loop
This commit is contained in:
@@ -31,6 +31,8 @@ class FileSource;
|
||||
class View;
|
||||
|
||||
class Map : private util::noncopyable {
|
||||
typedef void (*stop_callback)();
|
||||
|
||||
public:
|
||||
explicit Map(View &view);
|
||||
~Map();
|
||||
@@ -38,7 +40,7 @@ public:
|
||||
// Start/stop the map render thread. the start() call is asynchronous, while the stop() call
|
||||
// will block until the map rendering thread stopped.
|
||||
void start();
|
||||
void stop();
|
||||
void stop(stop_callback cb = nullptr);
|
||||
|
||||
// Runs the map event loop. ONLY run this function when you want to get render a single frame
|
||||
// with this map object. It will *not* spawn a separate thread and instead block until the
|
||||
@@ -179,6 +181,9 @@ private:
|
||||
// ready for rendering.
|
||||
std::atomic_flag is_rendered = ATOMIC_FLAG_INIT;
|
||||
|
||||
// Stores whether the map thread has been stopped already.
|
||||
std::atomic_bool is_stopped;
|
||||
|
||||
public:
|
||||
View &view;
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void notify() = 0;
|
||||
|
||||
// Notifies a watcher of map x/y/scale/rotation changes.
|
||||
// Must only be called from the same thread that caused the change.
|
||||
// Must not be called from the render thread.
|
||||
|
||||
Reference in New Issue
Block a user