diff options
author | J.J <thechairman@thechairman.info> | 2024-05-30 21:50:02 -0400 |
---|---|---|
committer | J.J <thechairman@thechairman.info> | 2024-05-30 21:50:02 -0400 |
commit | 612fd986ab1e00b6d34dc1937136250e08e89325 (patch) | |
tree | a3c93952040c6afdf348b5831619a45db7ba0a2e /aoc2023/build/packages/gleam_otp/src/gleam_otp.gleam | |
parent | 231c2b688d1e6cf0846d46e883da30e042a9c6cf (diff) | |
download | gleam_aoc-612fd986ab1e00b6d34dc1937136250e08e89325.tar.gz gleam_aoc-612fd986ab1e00b6d34dc1937136250e08e89325.zip |
cleanup
Diffstat (limited to 'aoc2023/build/packages/gleam_otp/src/gleam_otp.gleam')
-rw-r--r-- | aoc2023/build/packages/gleam_otp/src/gleam_otp.gleam | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/aoc2023/build/packages/gleam_otp/src/gleam_otp.gleam b/aoc2023/build/packages/gleam_otp/src/gleam_otp.gleam new file mode 100644 index 0000000..69cdd5b --- /dev/null +++ b/aoc2023/build/packages/gleam_otp/src/gleam_otp.gleam @@ -0,0 +1,27 @@ +import gleam/io +import gleam/int +import gleam/list +import gleam/otp/task +import gleam/erlang/process.{type Pid} + +@external(erlang, "gleam_otp_test_external", "get_message_queue_length") +fn get_message_queue_length(pid pid: Pid) -> Int + +fn spawn_task(i) { + task.async(fn() { + case i % 500 == 0 { + True -> io.println("Hello from " <> int.to_string(i)) + False -> Nil + } + }) +} + +pub fn main() { + io.debug(get_message_queue_length(process.self())) + + list.range(0, 1_000_000) + |> list.map(spawn_task) + |> list.each(task.await_forever) + + io.debug(get_message_queue_length(process.self())) +} |