mirror of
https://github.com/sbrow/thor.git
synced 2026-08-26 11:23:32 -04:00
perf: Parallelized grammar loading.
This commit is contained in:
@@ -15,6 +15,15 @@ when SPALL {
|
||||
spall_ctx: spall.Context
|
||||
@(thread_local)
|
||||
spall_buffer: spall.Buffer
|
||||
|
||||
init_spall_for_thread :: proc() {
|
||||
backing := make([]u8, spall.BUFFER_DEFAULT_SIZE, context.temp_allocator)
|
||||
spall_buffer = spall.buffer_create(backing, u32(sync.current_thread_id()))
|
||||
}
|
||||
|
||||
cleanup_spall_for_thread :: proc() {
|
||||
spall.buffer_destroy(&spall_ctx, &spall_buffer)
|
||||
}
|
||||
}
|
||||
|
||||
main :: proc() {
|
||||
@@ -40,6 +49,12 @@ main :: proc() {
|
||||
context.logger = console_logger
|
||||
defer log.destroy_console_logger(console_logger)
|
||||
|
||||
treesitter.init_persistent()
|
||||
|
||||
when SPALL {
|
||||
treesitter.set_thread_callbacks(init_spall_for_thread, cleanup_spall_for_thread)
|
||||
}
|
||||
|
||||
for {
|
||||
defer free_all(context.temp_allocator)
|
||||
tick := time.tick_now()
|
||||
|
||||
Reference in New Issue
Block a user