Optimize C# bindings in Engine code to static functions that native ABI matches managed signature

This commit is contained in:
Wojtek Figat
2022-02-19 00:29:09 +01:00
parent 71b9324bcb
commit 56491569df
11 changed files with 81 additions and 95 deletions

View File

@@ -180,7 +180,22 @@ void CodeEditingManager::OpenSolution(CodeEditorTypes editorType)
const auto editor = GetCodeEditor(editorType);
if (editor)
{
OpenSolution(editor);
// Ensure that no async task is running
if (IsAsyncOpenRunning())
{
// TODO: enqueue action and handle many actions in the queue
LOG(Warning, "Cannot use code editor during async open action.");
return;
}
if (editor->UseAsyncForOpen())
{
AsyncOpenTask::OpenSolution(editor);
}
else
{
editor->OpenSolution();
}
}
else
{
@@ -201,26 +216,6 @@ void CodeEditingManager::OnFileAdded(CodeEditorTypes editorType, const String& p
}
}
void CodeEditingManager::OpenSolution(CodeEditor* editor)
{
// Ensure that no async task is running
if (IsAsyncOpenRunning())
{
// TODO: enqueue action and handle many actions in the queue
LOG(Warning, "Cannot use code editor during async open action.");
return;
}
if (editor->UseAsyncForOpen())
{
AsyncOpenTask::OpenSolution(editor);
}
else
{
editor->OpenSolution();
}
}
void OnAsyncBegin(Thread* thread)
{
ASSERT(AsyncOpenThread == nullptr);

View File

@@ -193,12 +193,6 @@ public:
/// <param name="path">The path.</param>
API_FUNCTION() static void OnFileAdded(CodeEditorTypes editorType, const String& path);
/// <summary>
/// Opens the solution project. Handles async opening.
/// </summary>
/// <param name="editor">The code editor.</param>
static void OpenSolution(CodeEditor* editor);
/// <summary>
/// The asynchronous open begins.
/// </summary>

View File

@@ -156,7 +156,7 @@ bool ScriptsBuilder::IsSourceWorkspaceDirty()
return _wasProjectStructureChanged;
}
bool ScriptsBuilder::IsSourceDirty(const TimeSpan& timeout)
bool ScriptsBuilder::IsSourceDirtyFor(const TimeSpan& timeout)
{
ScopeLock scopeLock(_locker);
return _lastSourceCodeEdited > (_lastCompileAction + timeout);
@@ -626,7 +626,7 @@ void ScriptsBuilderService::Update()
// Check if compile code (if has been edited)
const TimeSpan timeToCallCompileIfDirty = TimeSpan::FromMilliseconds(50);
auto mainWindow = Engine::MainWindow;
if (ScriptsBuilder::IsSourceDirty(timeToCallCompileIfDirty) && mainWindow && mainWindow->IsFocused())
if (ScriptsBuilder::IsSourceDirtyFor(timeToCallCompileIfDirty) && mainWindow && mainWindow->IsFocused())
{
// Check if auto reload is enabled
if (Editor::Managed->CanAutoReloadScripts())

View File

@@ -63,7 +63,7 @@ public:
/// </summary>
/// <param name="timeout">Time to use for checking.</param>
/// <returns>True if source code is dirty, otherwise false.</returns>
static bool IsSourceDirty(const TimeSpan& timeout);
static bool IsSourceDirtyFor(const TimeSpan& timeout);
/// <summary>
/// Returns true if scripts are being now compiled/reloaded.