Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
flutter::GLFWEventLoop Class Reference

#include <glfw_event_loop.h>

Inheritance diagram for flutter::GLFWEventLoop:
flutter::EventLoop

Public Member Functions

 GLFWEventLoop (std::thread::id main_thread_id, const TaskExpiredCallback &on_task_expired)
 
virtual ~GLFWEventLoop ()
 
 GLFWEventLoop (const GLFWEventLoop &)=delete
 
GLFWEventLoopoperator= (const GLFWEventLoop &)=delete
 
- Public Member Functions inherited from flutter::EventLoop
 EventLoop (std::thread::id main_thread_id, const TaskExpiredCallback &on_task_expired)
 
virtual ~EventLoop ()
 
 EventLoop (const EventLoop &)=delete
 
EventLoopoperator= (const EventLoop &)=delete
 
bool RunsTasksOnCurrentThread () const
 
void WaitForEvents (std::chrono::nanoseconds max_wait=std::chrono::nanoseconds::max())
 
void PostTask (FlutterTask flutter_task, uint64_t flutter_target_time_nanos)
 

Private Member Functions

void WaitUntil (const TaskTimePoint &time) override
 
void Wake () override
 

Additional Inherited Members

- Public Types inherited from flutter::EventLoop
using TaskExpiredCallback = std::function< void(const FlutterTask *)>
 
- Protected Types inherited from flutter::EventLoop
using TaskTimePoint = std::chrono::steady_clock::time_point
 
- Protected Member Functions inherited from flutter::EventLoop
std::mutex & GetTaskQueueMutex ()
 
- Static Protected Member Functions inherited from flutter::EventLoop
static TaskTimePoint TimePointFromFlutterTime (uint64_t flutter_target_time_nanos)
 
- Protected Attributes inherited from flutter::EventLoop
std::thread::id main_thread_id_
 
TaskExpiredCallback on_task_expired_
 
std::mutex task_queue_mutex_
 
std::priority_queue< Task, std::deque< Task >, Task::Comparertask_queue_
 

Detailed Description

Definition at line 14 of file glfw_event_loop.h.

Constructor & Destructor Documentation

◆ GLFWEventLoop() [1/2]

flutter::GLFWEventLoop::GLFWEventLoop ( std::thread::id  main_thread_id,
const TaskExpiredCallback on_task_expired 
)

Definition at line 14 of file glfw_event_loop.cc.

16 : EventLoop(main_thread_id, on_task_expired) {}
EventLoop(std::thread::id main_thread_id, const TaskExpiredCallback &on_task_expired)
Definition event_loop.cc:12

◆ ~GLFWEventLoop()

flutter::GLFWEventLoop::~GLFWEventLoop ( )
virtualdefault

◆ GLFWEventLoop() [2/2]

flutter::GLFWEventLoop::GLFWEventLoop ( const GLFWEventLoop )
delete

Member Function Documentation

◆ operator=()

GLFWEventLoop & flutter::GLFWEventLoop::operator= ( const GLFWEventLoop )
delete

◆ WaitUntil()

void flutter::GLFWEventLoop::WaitUntil ( const TaskTimePoint time)
overrideprivatevirtual

Implements flutter::EventLoop.

Definition at line 20 of file glfw_event_loop.cc.

20 {
21 const auto now = TaskTimePoint::clock::now();
22
23 // Make sure the seconds are not integral.
24 using Seconds = std::chrono::duration<double, std::ratio<1>>;
25 const auto duration_to_wait = std::chrono::duration_cast<Seconds>(time - now);
26
27 if (duration_to_wait.count() > 0.0) {
28 ::glfwWaitEventsTimeout(duration_to_wait.count());
29 } else {
30 // Avoid engine task priority inversion by making sure GLFW events are
31 // always processed even when there is no need to wait for pending engine
32 // tasks.
33 ::glfwPollEvents();
34 }
35}

◆ Wake()

void flutter::GLFWEventLoop::Wake ( )
overrideprivatevirtual

Implements flutter::EventLoop.

Definition at line 37 of file glfw_event_loop.cc.

37 {
38 ::glfwPostEmptyEvent();
39}

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