vatnar revised this gist 1 week ago. Go to revision
1 file changed, 18 insertions
scratch.cpp(file created)
| @@ -0,0 +1,18 @@ | |||
| 1 | + | inline Arena *get_scratch(Arena **conflicts, u64 count) { | |
| 2 | + | if (!g_thread_ctx.scratch_arenas[0]) { | |
| 3 | + | thread_ctx_init(); | |
| 4 | + | } | |
| 5 | + | for (u64 i = 0; i < 2; i++) { | |
| 6 | + | bool has_conflict = false; | |
| 7 | + | for (u64 j = 0; j < count; j++) { | |
| 8 | + | if (g_thread_ctx.scratch_arenas[i] == conflicts[j]) { | |
| 9 | + | has_conflict = true; | |
| 10 | + | break; | |
| 11 | + | } | |
| 12 | + | } | |
| 13 | + | if (!has_conflict) { | |
| 14 | + | return g_thread_ctx.scratch_arenas[i]; | |
| 15 | + | } | |
| 16 | + | } | |
| 17 | + | TRAP(); | |
| 18 | + | } | |
Newer
Older