Add Job System (#656)
* Add Job System * Remove testing stuff * changelog * plugin work * Convert a couple more jobs * simplify callback * assert * Logging changes and rendezvous perf * changelog * sb segment viewed job * clear cache, and few changes * Lint fix * a couple more jobs * reduce rendezvous in web server * refactor * Lint fix * no message * test shutdown * comment * free fields --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
45983a67af
commit
d70a07049a
74 files changed
+1090
-298
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace Assert
|
||||
|
||||
function IsTrue(condition as dynamic, message = invalid as dynamic) as void
|
||||
if not ValidBool(condition)
|
||||
throw "Assertion failed: " + ToString(message)
|
||||
end if
|
||||
end function
|
||||
|
||||
function IsFalse(condition as dynamic, message = invalid as dynamic) as void
|
||||
if ValidBool(condition)
|
||||
throw "Assertion failed: " + ToString(message)
|
||||
end if
|
||||
end function
|
||||
|
||||
function IsValid(value as dynamic, message = invalid as dynamic) as void
|
||||
if value = invalid
|
||||
throw "Assertion failed: " + ToString(message)
|
||||
end if
|
||||
end function
|
||||
|
||||
function AreEqual(expected as dynamic, actual as dynamic, message = invalid as dynamic) as void
|
||||
if expected <> actual
|
||||
throw "Assertion failed: Expected " + ToString(expected) + ", but got " + ToString(actual) + ". " + ToString(message)
|
||||
end if
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -1,10 +1,10 @@
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/components/JobSystem/Jobs.bs"
|
||||
import "pkg:/components/JobSystem/JobSystem.bs"
|
||||
|
||||
namespace CacheUtils
|
||||
|
||||
function Clear()
|
||||
AsyncTask.Start(Tasks.ClearCacheTask, invalid)
|
||||
function Clear(jobQueue as object)
|
||||
JobSystem.QueueJob(jobQueue, Jobs.ClearCacheJob)
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -3,6 +3,18 @@ import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace CancellationUtils
|
||||
|
||||
function CreateCancellation(node as dynamic, field as string, value as dynamic) as dynamic
|
||||
if node = invalid or field = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
return {
|
||||
"node": node
|
||||
"field": field
|
||||
"value": value
|
||||
}
|
||||
end function
|
||||
|
||||
function IsCancelled(cancellation as dynamic) as boolean
|
||||
if cancellation = invalid or cancellation.node = invalid or cancellation.field = invalid
|
||||
return false
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
|
||||
@asynctask
|
||||
function ClearCacheTask() as object
|
||||
fs = CreateObject("roFileSystem")
|
||||
if fs = invalid
|
||||
LogError("Failed to create roFileSystem object")
|
||||
return invalid
|
||||
end if
|
||||
|
||||
ClearVolume(fs, "tmp:/")
|
||||
ClearVolume(fs, "cachefs:/")
|
||||
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function ClearVolume(fs as object, volume as string)
|
||||
items = fs.GetDirectoryListing(volume)
|
||||
for each item in items
|
||||
fullpath = volume + item
|
||||
|
||||
' Skip logs directory
|
||||
if fullpath = "cachefs:/logs"
|
||||
continue for
|
||||
end if
|
||||
|
||||
if not fs.Delete(fullpath)
|
||||
LogError("Failed to delete:", fullpath)
|
||||
end if
|
||||
end for
|
||||
|
||||
LogInfo("Cleared:", volume)
|
||||
end function
|
||||
@@ -31,7 +31,7 @@ namespace DebugUtils
|
||||
out += `\n` + "║ " + line + string(maxLen - line.len(), " ") + " ║"
|
||||
end for
|
||||
out += `\n` + "╚" + string(maxLen + 2, "═") + "╝"
|
||||
? out
|
||||
print out
|
||||
#end if
|
||||
end function
|
||||
end namespace
|
||||
@@ -37,5 +37,9 @@ namespace StringUtils
|
||||
end if
|
||||
return input.Mid(startIndex, endIndex - startIndex)
|
||||
end function
|
||||
|
||||
function RandomId() as string
|
||||
return StrI(rnd(2147483647), 36)
|
||||
end function
|
||||
end namespace
|
||||
|
||||
Reference in new issue
Block a user