r.x0 += (200.0f / ~~workers_used.count);
r.x1 = r.x0 + (200.0f / ~~workers_used.count);
}
+
+ r.x0 = clear_button_rect.x0;
+ r.x1 = clear_button_rect.x1;
+ r.y0 += 50;
+ r.y1 += 25;
+
+ buf: [128] u8;
+ ui.draw_text(r, conv.str_format(buf, "H: {}\n", alloc.heap.get_watermark()));
}
#private_file log_buffer : struct {
sync.mutex_unlock(^work_unit_mutex);
}
-work_unit_insert :: (w: ^Work_Unit) {
- sync.mutex_lock(^work_unit_mutex);
-
- if first_work_unit == null {
- first_work_unit = w;
- } else {
- work_unit := first_work_unit;
- while work_unit.next != null do work_unit = work_unit.next;
-
- work_unit.next = w;
- }
-
- sync.semaphore_post(^work_unit_signal, 1);
- sync.mutex_unlock(^work_unit_mutex);
-}
-
workers_being_used :: () -> [WORKER_COUNT] bool {
used: [WORKER_COUNT] bool;
for i: WORKER_COUNT {
work_unit_buffer : [] Work_Unit;
work_unit_pool : alloc.pool.PoolAllocator(Work_Unit);
-next_work_unit_id : i32;
+next_work_unit_id := 0;
first_work_unit : ^Work_Unit;
work_unit_mutex : sync.Mutex;
work_unit_signal : sync.Semaphore;
+work_unit_insert :: (w: ^Work_Unit) {
+ sync.mutex_lock(^work_unit_mutex);
+
+ if first_work_unit == null {
+ first_work_unit = w;
+ } else {
+ work_unit := first_work_unit;
+ while work_unit.next != null do work_unit = work_unit.next;
+
+ work_unit.next = w;
+ }
+
+ sync.semaphore_post(^work_unit_signal, 1);
+ sync.mutex_unlock(^work_unit_mutex);
+}
+
+work_unit_done :: (w: ^Work_Unit) {
+ sync.mutex_lock(^work_unit_mutex);
+ alloc.pool.pool_free(^work_unit_pool, w);
+ sync.mutex_unlock(^work_unit_mutex);
+}
+
work_unit_processor :: (thread_data: ^Worker_Data) {
while true {
sync.semaphore_wait(^work_unit_signal);
switch result {
case .Failed {
debug_log(.Error, "Work unit {} failed.", next_work_unit_id);
+ fallthrough;
+ }
+
+ case .Success {
+ work_unit_done(work_unit);
}
case .Not_Done {
}
}
-}
\ No newline at end of file
+}
package feature.hex_viewer
#private_file {
- app :: package app
+ app :: package app
editor :: package editor
- ui :: package ui
+ ui :: package ui
config :: package config
-}
-use package core
-use package debug { debug_log }
+ use package core
+ use package debug { debug_log }
+}
-window_id :: "hex_viewer"
+window_id :: "hex_viewer"
window_name :: "Hex Viewer"
Hex_Viewer_State :: struct {
win.window_state.max_size.x = (10 + 1 + 3 * 16 + 2 + 16) * em_height;
if !app.state.has_active_file {
+ text_theme.font_size = 5.0f;
ui.draw_text(r, "No loaded file.", theme=^text_theme);
return;
}
}
open_window :: () {
- app.open_window(window_id, window_name, .{ 0, 0 }, window_draw, .{ 1300, 650 }, draw_data=^global_viewer_state);
+ app.open_window(window_id, window_name, .zero, window_draw, .{1300,650}, draw_data=^global_viewer_state);
app.move_window_to_top(window_id);
app.focus_window(window_id);
- app.open_window("dummy", "DUMMY TESTING", .{ 0, 0 },
+ app.open_window("dummy", "DUMMY TESTING", .zero,
(_, win) => { (package editor).editor_window_draw(hex_window, win); });
}
file_data := app.state.file.data;
debug_log(.Info, "Wasm feature noticed file dropped with size {}", file_data.count);
- if !string.starts_with(file_data, u8.[ 0, #char "a", #char "s", #char "m" ]) do return app.Work_Unit_Status.Failed;
+ if !string.starts_with(file_data, u8.[ 0, #char "a", #char "s", #char "m" ]) do return .Failed;
debug_log(.Info, "THIS IS PROBABLY A WASM BINARY. ANALYZING!!!");
wasm_analyzed = true;
- return app.Work_Unit_Status.Success;
+ return .Success;
}
file_loaded :: () {
app.work_unit_submit(null, process_file);
- // thread.spawn(^wasm_processing_thread, null, process_file);
}
button_rect : Rectangle;
- for option: options |> iter.from_array() |> iter.enumerate() {
+ idx := 0;
+ for ^option: options {
+ defer idx += 1;
+
button_rect, menu_rect = Flow.split_vertical(menu_rect, left_width=100);
- if button(Flow.padding(button_rect, right=4), option.value.label, theme=^menu_button_theme, increment=option.index) {
- option.value.action();
+ if button(Flow.padding(button_rect, right=4), option.label, theme=^menu_button_theme, increment=idx) {
+ option.action();
}
}