MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mbgl::util::RunLoop Class Reference

#include <run_loop.hpp>

Inheritance diagram for mbgl::util::RunLoop:
mbgl::Scheduler mbgl::util::non_copyable_::noncopyable

Public Types

enum class  Type : uint8_t { Default , New }
 
enum class  Priority : bool { Default = false , High = true }
 
enum class  Event : uint8_t { None = 0 , Read = 1 , Write = 2 , ReadWrite = Read | Write }
 

Public Member Functions

 RunLoop (Type type=Type::Default)
 
 ~RunLoop () override
 
void run ()
 
void runOnce ()
 
void stop ()
 
void setPlatformCallback (std::function< void()> callback)
 
void addWatch (int fd, Event, std::function< void(int, Event)> &&callback)
 
void removeWatch (int fd)
 
template<class Fn , class... Args>
void invoke (Priority priority, Fn &&fn, Args &&... args)
 
template<class Fn , class... Args>
void invoke (Fn &&fn, Args &&... args)
 
template<class Fn , class... Args>
std::unique_ptr< AsyncRequestinvokeCancellable (Fn &&fn, Args &&... args)
 
void schedule (std::function< void()> fn) override
 Enqueues a function for execution. More...
 
::mapbox::base::WeakPtr< SchedulermakeWeakPtr () override
 Makes a weak pointer to this Scheduler. More...
 
- Public Member Functions inherited from mbgl::Scheduler
virtual ~Scheduler ()=default
 
std::function< void()> bindOnce (std::function< void()>)
 
template<typename TaskFn , typename ReplyFn >
void scheduleAndReplyValue (const TaskFn &task, const ReplyFn &reply)
 

Static Public Member Functions

static RunLoopGet ()
 
static LOOP_HANDLE getLoopHandle ()
 
- Static Public Member Functions inherited from mbgl::Scheduler
static SchedulerGetCurrent ()
 Set/Get the current Scheduler for this thread. More...
 
static void SetCurrent (Scheduler *)
 
static std::shared_ptr< SchedulerGetBackground ()
 
static std::shared_ptr< SchedulerGetSequenced ()
 

Additional Inherited Members

- Protected Member Functions inherited from mbgl::Scheduler
template<typename TaskFn , typename ReplyFn >
void scheduleAndReplyValue (const TaskFn &task, const ReplyFn &reply, mapbox::base::WeakPtr< Scheduler > replyScheduler)
 

Detailed Description

Definition at line 21 of file run_loop.hpp.

Member Enumeration Documentation

◆ Event

enum mbgl::util::RunLoop::Event : uint8_t
strong
Enumerator
None 
Read 
Write 
ReadWrite 

Definition at line 34 of file run_loop.hpp.

◆ Priority

enum mbgl::util::RunLoop::Priority : bool
strong
Enumerator
Default 
High 

Definition at line 29 of file run_loop.hpp.

◆ Type

enum mbgl::util::RunLoop::Type : uint8_t
strong
Enumerator
Default 
New 

Definition at line 24 of file run_loop.hpp.

Constructor & Destructor Documentation

◆ RunLoop()

mbgl::util::RunLoop::RunLoop ( Type  type = Type::Default)

◆ ~RunLoop()

mbgl::util::RunLoop::~RunLoop ( )
override

Member Function Documentation

◆ addWatch()

void mbgl::util::RunLoop::addWatch ( int  fd,
Event  ,
std::function< void(int, Event)> &&  callback 
)

◆ Get()

static RunLoop* mbgl::util::RunLoop::Get ( )
static

◆ getLoopHandle()

static LOOP_HANDLE mbgl::util::RunLoop::getLoopHandle ( )
static

◆ invoke() [1/2]

template<class Fn , class... Args>
void mbgl::util::RunLoop::invoke ( Fn &&  fn,
Args &&...  args 
)
inline

Definition at line 70 of file run_loop.hpp.

◆ invoke() [2/2]

template<class Fn , class... Args>
void mbgl::util::RunLoop::invoke ( Priority  priority,
Fn &&  fn,
Args &&...  args 
)
inline

Definition at line 64 of file run_loop.hpp.

◆ invokeCancellable()

template<class Fn , class... Args>
std::unique_ptr<AsyncRequest> mbgl::util::RunLoop::invokeCancellable ( Fn &&  fn,
Args &&...  args 
)
inline

Definition at line 77 of file run_loop.hpp.

◆ makeWeakPtr()

::mapbox::base::WeakPtr<Scheduler> mbgl::util::RunLoop::makeWeakPtr ( )
inlineoverridevirtual

Makes a weak pointer to this Scheduler.

Implements mbgl::Scheduler.

Definition at line 84 of file run_loop.hpp.

◆ removeWatch()

void mbgl::util::RunLoop::removeWatch ( int  fd)

◆ run()

void mbgl::util::RunLoop::run ( )

◆ runOnce()

void mbgl::util::RunLoop::runOnce ( )

◆ schedule()

void mbgl::util::RunLoop::schedule ( std::function< void()>  )
inlineoverridevirtual

Enqueues a function for execution.

Implements mbgl::Scheduler.

Definition at line 83 of file run_loop.hpp.

◆ setPlatformCallback()

void mbgl::util::RunLoop::setPlatformCallback ( std::function< void()>  callback)
inline

Platform integration callback for platforms that do not have full run loop integration or don't want to block at the Mapbox GL Native loop. It will be called from any thread and is up to the platform to, after receiving the callback, call RunLoop::runOnce() from the same thread as the Map object lives.

Definition at line 56 of file run_loop.hpp.

◆ stop()

void mbgl::util::RunLoop::stop ( )

The documentation for this class was generated from the following file: