mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 08:22:45 +00:00 
			
		
		
		
	 909e522cf7
			
		
	
	
		909e522cf7
		
	
	
	
	
		
			
			Since we can't simply give HTML::EventLoop control of the whole program, we have to integrate with Core::EventLoop. We do this by having a single-shot 0ms Core::Timer that we start when a task is added to the queue, and restart after processing the queue and there are still tasks in the queue.
		
			
				
	
	
		
			27 lines
		
	
	
	
		
			456 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
	
		
			456 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibWeb/HTML/EventLoop/EventLoop.h>
 | |
| #include <LibWeb/HTML/EventLoop/TaskQueue.h>
 | |
| 
 | |
| namespace Web::HTML {
 | |
| 
 | |
| TaskQueue::TaskQueue(HTML::EventLoop& event_loop)
 | |
|     : m_event_loop(event_loop)
 | |
| {
 | |
| }
 | |
| 
 | |
| TaskQueue::~TaskQueue()
 | |
| {
 | |
| }
 | |
| 
 | |
| void TaskQueue::add(NonnullOwnPtr<Task> task)
 | |
| {
 | |
|     m_tasks.enqueue(move(task));
 | |
|     m_event_loop.schedule();
 | |
| }
 | |
| 
 | |
| }
 |