pavpanchekha
2019-6-22 18:28:26

I’ve used Places to do multi-threading


pavpanchekha
2019-6-22 18:29:11

It’s kind of a pain, because I often use parameters to set global variables, and you need to have a kind of “setup” phase where you send all of your global variables to all of the new places


pavpanchekha
2019-6-22 18:29:24

But on the other hand, it is very safe and there aren’t any threading bugs, which is a joy


pavpanchekha
2019-6-22 18:29:42

It feels a lot like using “multiprocessing” in Python


pavpanchekha
2019-6-22 18:30:39

The second biggest frustration has been that Places is designed for distribution as well as multiprocessing, which means only serializable data can be sent across the channels. That limitation is frustrating in a single address space


pavpanchekha
2019-6-22 18:30:58

But while this constrains the initial design, it isn’t much of a problem moving forward


pavpanchekha
2019-6-22 18:33:00

Oh, there’s another frustration due to its implementation with a quasi-separate-process implementation: you can’t write a parallel-for implementation as a function, because once you spawn the child threads you can’t send them a function to run, and they can’t access that function from lexical scope.


pavpanchekha
2019-6-22 18:34:09

In Cassius I have a parallel-for macro (for/threads in src/report.rkt) but even then it’s project-specific since it has to send over parameter values


pavpanchekha
2019-6-22 18:37:38

Hmm, also there’s some annoyance with sync: when you sync over a list of thread channels, you aren’t told which thread sent the message you receive, so you can’t send it new work. I use a weird protocol where the manager thread sends each worker the other end of its channel, and the worker sends “itself” back to the manager when it’s done with its work.


pavpanchekha
2019-6-22 18:37:45

That took a while to figure out but is basically good now.


sorawee
2019-6-22 21:46:29

Say, I want to create struct definitions to represent syntax object. It seems there are two ways I can do it. One is to make struct definitions completely independent, and then have (define my-syntax? (disjoin …..)). Another is creating a dummy struct named my-syntax, and have every syntax struct inherits it. Which one is more idiomatic?


notjack
2019-6-23 05:22:32

@sorawee I think the latter is more idiomatic to most racketeers but I personally prefer the former, because I find it easier to just outright ban subtyping