#ifndef MBGL_UTIL_WORK_QUEUE #define MBGL_UTIL_WORK_QUEUE #include #include #include #include #include #include namespace mbgl { namespace util { class RunLoop; // The WorkQueue will manage a queue of closures // and it will make sure they get executed on the // thread that created the WorkQueue. All pending // works are canceled when the queue gets destructed. class WorkQueue : private util::noncopyable { public: WorkQueue(); ~WorkQueue(); // Push a closure to the queue. It is advised to // only push tasks calling functions on the object // that owns the queue to avoid use after free errors. void push(std::function&&); private: void pop(const std::function&); std::queue> queue; std::mutex queueMutex; RunLoop* runLoop; }; } // namespace util } // namespace mbgl #endif