-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move EventLoopTask into a separate file because it causes clangd to c…
…rash (#13875)
- Loading branch information
1 parent
4a58a97
commit 97baeb8
Showing
8 changed files
with
65 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "root.h" | ||
#include "EventLoopTask.h" | ||
|
||
namespace WebCore { | ||
class DeleteCallbackDataTask : public EventLoopTask { | ||
public: | ||
template<typename CallbackDataType> | ||
explicit DeleteCallbackDataTask(CallbackDataType* data) | ||
: EventLoopTask(EventLoopTask::CleanupTask, [data](ScriptExecutionContext&) mutable { | ||
delete data; | ||
}) | ||
{ | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "root.h" | ||
#include "ScriptExecutionContext.h" | ||
|
||
namespace WebCore { | ||
|
||
class EventLoopTask { | ||
WTF_MAKE_ISO_ALLOCATED(EventLoopTask); | ||
|
||
public: | ||
enum CleanupTaskTag { CleanupTask }; | ||
|
||
template<typename T, typename = typename std::enable_if<!std::is_base_of<EventLoopTask, T>::value && std::is_convertible<T, Function<void(ScriptExecutionContext&)>>::value>::type> | ||
EventLoopTask(T task) | ||
: m_task(WTFMove(task)) | ||
, m_isCleanupTask(false) | ||
{ | ||
} | ||
|
||
EventLoopTask(Function<void()>&& task) | ||
: m_task([task = WTFMove(task)](ScriptExecutionContext&) { task(); }) | ||
, m_isCleanupTask(false) | ||
{ | ||
} | ||
|
||
template<typename T, typename = typename std::enable_if<std::is_convertible<T, Function<void(ScriptExecutionContext&)>>::value>::type> | ||
EventLoopTask(CleanupTaskTag, T task) | ||
: m_task(WTFMove(task)) | ||
, m_isCleanupTask(true) | ||
{ | ||
} | ||
|
||
void performTask(ScriptExecutionContext& context) | ||
{ | ||
m_task(context); | ||
delete this; | ||
} | ||
bool isCleanupTask() const { return m_isCleanupTask; } | ||
|
||
protected: | ||
Function<void(ScriptExecutionContext&)> m_task; | ||
bool m_isCleanupTask; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters