diff --git a/core/sync/barrier.odin b/core/sync/barrier.odin index 997fde82d..13c870a3b 100644 --- a/core/sync/barrier.odin +++ b/core/sync/barrier.odin @@ -1,44 +1,43 @@ package sync -// A barrier enabling multiple threads to synchronize the beginning of some computation /* - * Example: - * - * package example - * - * import "core:fmt" - * import "core:sync" - * import "core:thread" - * - * barrier := &sync.Barrier{}; - * - * main :: proc() { - * fmt.println("Start"); - * - * THREAD_COUNT :: 4; - * threads: [THREAD_COUNT]^thread.Thread; - * - * sync.barrier_init(barrier, THREAD_COUNT); - * defer sync.barrier_destroy(barrier); - * - * - * for _, i in threads { - * threads[i] = thread.create_and_start(proc(t: ^thread.Thread) { - * // Same messages will be printed together but without any interleaving - * fmt.println("Getting ready!"); - * sync.barrier_wait(barrier); - * fmt.println("Off their marks they go!"); - * }); - * } - * - * for t in threads { - * thread.destroy(t); // join and free thread - * } - * fmt.println("Finished"); - * } - * - */ +A barrier enabling multiple threads to synchronize the beginning of some computation +Example: + + package example + + import "core:fmt" + import "core:sync" + import "core:thread" + + barrier := &sync.Barrier{}; + + main :: proc() { + fmt.println("Start"); + + THREAD_COUNT :: 4; + threads: [THREAD_COUNT]^thread.Thread; + + sync.barrier_init(barrier, THREAD_COUNT); + defer sync.barrier_destroy(barrier); + + + for _, i in threads { + threads[i] = thread.create_and_start(proc(t: ^thread.Thread) { + // Same messages will be printed together but without any interleaving + fmt.println("Getting ready!"); + sync.barrier_wait(barrier); + fmt.println("Off their marks they go!"); + }); + } + + for t in threads { + thread.destroy(t); // join and free thread + } + fmt.println("Finished"); + } +*/ Barrier :: struct { mutex: Blocking_Mutex, cond: Condition, diff --git a/core/sync/sync2/extended.odin b/core/sync/sync2/extended.odin index d6a99fe04..deb48a22d 100644 --- a/core/sync/sync2/extended.odin +++ b/core/sync/sync2/extended.odin @@ -67,44 +67,41 @@ wait_group_wait_with_timeout :: proc(wg: ^Wait_Group, duration: time.Duration) - -// A barrier enabling multiple threads to synchronize the beginning of some computation /* - * Example: - * - * package example - * - * import "core:fmt" - * import "core:sync" - * import "core:thread" - * - * barrier := &sync.Barrier{} - * - * main :: proc() { - * fmt.println("Start") - * - * THREAD_COUNT :: 4 - * threads: [THREAD_COUNT]^thread.Thread - * - * sync.barrier_init(barrier, THREAD_COUNT) - * defer sync.barrier_destroy(barrier) - * - * - * for _, i in threads { - * threads[i] = thread.create_and_start(proc(t: ^thread.Thread) { - * // Same messages will be printed together but without any interleaving - * fmt.println("Getting ready!") - * sync.barrier_wait(barrier) - * fmt.println("Off their marks they go!") - * }) - * } - * - * for t in threads { - * thread.destroy(t) // join and free thread - * } - * fmt.println("Finished") - * } - * - */ +A barrier enabling multiple threads to synchronize the beginning of some computation + +Example: + package example + + import "core:fmt" + import "core:sync" + import "core:thread" + + barrier := &sync.Barrier{} + + main :: proc() { + fmt.println("Start") + + THREAD_COUNT :: 4 + threads: [THREAD_COUNT]^thread.Thread + + sync.barrier_init(barrier, THREAD_COUNT) + + for _, i in threads { + threads[i] = thread.create_and_start(proc(t: ^thread.Thread) { + // Same messages will be printed together but without any interleaving + fmt.println("Getting ready!") + sync.barrier_wait(barrier) + fmt.println("Off their marks they go!") + }) + } + + for t in threads { + thread.destroy(t) // join and free thread + } + fmt.println("Finished") + } +*/ Barrier :: struct { mutex: Mutex, cond: Cond, diff --git a/tools/odin-html-docs/odin_html_docs_main.odin b/tools/odin-html-docs/odin_html_docs_main.odin index b9d9f37a6..89a82ad77 100644 --- a/tools/odin-html-docs/odin_html_docs_main.odin +++ b/tools/odin-html-docs/odin_html_docs_main.odin @@ -802,21 +802,31 @@ write_docs :: proc(w: io.Writer, pkg: ^doc.Pkg, docs: string) { it := docs was_code := true was_paragraph := true + prev_line: string for line in strings.split_iterator(&it, "\n") { + text := strings.trim_space(line) + defer prev_line = line + if strings.has_prefix(line, "\t") { if !was_code { was_code = true; - fmt.wprint(w, `
`)
+ if prev_line == "Example:" {
+ fmt.wprint(w, ``)
+ } else {
+ fmt.wprint(w, ``)
+ }
}
fmt.wprintf(w, "%s\n", strings.trim_prefix(line, "\t"))
continue
} else if was_code {
+ if text == "" {
+ continue
+ }
was_code = false
fmt.wprintln(w, "
")
- continue
}
- text := strings.trim_space(line)
if text == "" {
+
if was_paragraph {
was_paragraph = false
fmt.wprintln(w, "")