Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

hamidb80/asyncanything

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

always go async

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages