nibi-lang / nibi

An interpreted list processing language inspired by Lisp
GNU Affero General Public License v3.0
3 stars 2 forks source link

Functionality: threading/ async #128

Closed bosley closed 1 year ago

bosley commented 1 year ago

Create a means to call functions in a thread or using async.

This will entail setting up a means to mutex data.

Consider making a "bridge"/ "channel" cell or something similar that could hold a thread-safe queue or something to pipe data through thread barriers. - This last bit might be best done as its own module, and operate something like:

(:= x (chan::new))
(chan::submit x some_var)

(if (chan::ready)
    (:= next (chan::get)))

Though, it may be possible to do this easily with a standard list cell and a function that mutexes the pushes and pops?

This will require experimentation.

bosley commented 1 year ago
(:= fut_name (future (fn p1 p2 p3 p4)))

(assert (eq true (fut_name.is_valid)))

(fut_name.wait_for 100)

(if (eq true (fut_name.is_ready)) (io::println "READY"))

(:= result (fut_name.get))
bosley commented 1 year ago

Using these futures we could setup things to process, then defer the retrieval and returning of them.

bosley commented 1 year ago

https://github.com/nibi-lang/nibi/pull/141