diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-07-26 23:39:50 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-07-26 23:39:50 +0200 |
| commit | 97062d1e57bcf14f07d4fda95cf4b993880471b2 (patch) | |
| tree | e0df1005fac11d15ce5d3009a7566b9b82d52831 /src | |
| parent | ff540199891347486868a8a3bac1dce53947cf7f (diff) | |
Switching to virtual arena instead of ring buffer
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.odin | 6 | ||||
| -rw-r--r-- | src/server/requests.odin | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/main.odin b/src/main.odin index 6ef4778..73eecc2 100644 --- a/src/main.odin +++ b/src/main.odin @@ -11,6 +11,7 @@ import "core:thread" import "core:encoding/json" import "core:reflect" import "core:sync" +import "core:mem/virtual" import "core:intrinsics" @@ -99,7 +100,10 @@ main :: proc() { context.logger = log.create_file_logger(fh, log.Level.Info) */ - init_global_temporary_allocator(mem.Megabyte*10) + + growing_arena: virtual.Growing_Arena + + context.temp_allocator = virtual.growing_arena_allocator(&growing_arena) run(&reader, &writer) } diff --git a/src/server/requests.odin b/src/server/requests.odin index 47f0d74..b7774d5 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -271,7 +271,8 @@ notification_map: map [string] bool = { } consume_requests :: proc (config: ^common.Config, writer: ^Writer) -> bool { - temp_requests := make([dynamic]Request, 0, context.temp_allocator) + temp_requests := make([dynamic]Request, 0, context.allocator) + defer delete(temp_requests) sync.mutex_lock(&requests_mutex) @@ -301,6 +302,7 @@ consume_requests :: proc (config: ^common.Config, writer: ^Writer) -> bool { request := temp_requests[request_index] call(request.value, request.id, writer, config) json.destroy_value(request.value) + free_all(context.temp_allocator) } sync.mutex_lock(&requests_mutex) |