No description
Find a file
2022-02-19 19:57:38 +03:30
src add failed tests 2022-02-19 19:57:38 +03:30
tests add failed tests 2022-02-19 19:57:38 +03:30
.gitignore init 2021-10-21 10:42:31 +03:30
asyncanything.nimble bug fixes 2022-02-19 19:23:29 +03:30
readme.md add failed tests 2022-02-19 19:57:38 +03:30

make anything async with AsyncAnything!

imagine you have a heavy function in the main Event-Loop

proc AssumeItsHugeAmountOfWork(a: int): int=
  sleep 1000 * 10
  return a + 1

with this small library you can pass it to another thread and fake it as a async function! Wow you're a genius!

let b = goAsync AssumeItsHugeAmountOfWork()
# or
let b = |>AssumeItsHugeAmountOfWork()

the idea is that you pass it to another thread and you check it every timeout milliseconds. you can pass the timeout like this:

let b = goAsync(AssumeItsHugeAmountOfWork(), 100)

but by default it's value is fakeAsyncTimeout which is 100. you can also change it's value at the compile time with -d:fakeAsyncTimeout=<N> to your ideal timeout [ here <N> is an integer ]

limitations

there are some limitation when you want to run a non-return closure proc.