-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Mutex, Atom, Channel and Exhaustable Channel in stdlib/synch #1909
base: master
Are you sure you want to change the base?
Conversation
Ping @andychu |
Hm, "synch" (as from the last pull request) sounded so unfamilar to me that I didn't know what it was referring to before looking into it. If it would have read "sync" it would have been clear to me. Overall, maybe name it, e.g. |
The name is borrowed from Berkeley's Pintos' https://inst.eecs.berkeley.edu/~cs162/su20/static/projects/proj0-intro.pdf I'm up to a more conventional name, but |
Therefore I thought of proc_sync.ysh or even better to understand: process_sync.ysh |
Makes sense. Also waiting for comments from andy. |
Thanks for doing this! I skimmed over the code, I think this is cool I like that you are testing the language -- in particular I'm interested in netstrings And the int(s, n) feedback is good, we should have that This is exactly what we need to flesh out the language Though I still question if it needs to be in the stdlib, i.e. what applications can be written with this. Part of me suspects this is more like Go's domain -- and Go is going to do it better i.e. a shell can call Go programs, and JSON RPC programs, and HTTP programs like curl It's a little more of the "control plane" whereas this is kind of a "Data plane" solution in pure shell (I even have a blog post draft about this - #blog-ideas > The Worst Amount of Shell is 0% or 100% -- i.e. I don't necessarily believe in the "pure bash bible" which shows you how to do everthing in shell itself This is still marked "draft", but I wonder if it should be in Or we can wait on that decision until there are some apps built with it (again I suggest the minimal things for xargs and make) Our philosophy is a bit more like Rust than Go/Python. The stdlib should be minimal and other code should be outside. Whereas Go/Python build a lot of stuff in the stdlib. |
e.g. maybe to make it concrete -- would you use this in your YSH dotfiles ? I think you don't really need it for parallelism, and can use a higher level solution but maybe I'm wrong (I still need to take a closer look at how that works) Also do you have a lobste.rs account? I can send you an invite if not It would be cool to post some of this there, and on Reddit, to show people what can be done with the language |
Rust has std::sync https://doc.rust-lang.org/std/sync/ |
stdlib/draft-synch.ysh
Outdated
} | ||
|
||
# NOTE: I would love to optimize this a bit more, for example netstring of size n | ||
# now takes log_10(n) over head. We can certainly do this better by byte encoding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a non-issue. log base 10 is fine in practice :)
1MB message takes ~7 bytes
Netstrings are fast and efficient :)
I don't use lobsters, what is it? |
As for control vs data. I would say sometimes you have to touch the data to do control. e.g. we may use bash for a simple router that routes data requests based on first few bytes of the input to different applications. For higher level parallelism, we may take clojure's inspiration, but none of those can be implemented without proper lambdas. Also even clojure provides some low level primitives like atom. I think you may assume my solutions here too low level just because of the naming? They're actually pretty high level. And some low level primitives are needed for implementation of higher level one and yes we don't recommend using them in application level codes. And I think the line for shell and binary applications should be drawn by end user rather than the library designer. |
General Info
This PR implement several sync primitives, in order to implement Channel and Exhaustable Channel.
Dependency relation
PipeMethods is an interface
Descriptions
All of the above pass untyped data.
Non-POSIX dependencies
TODOs
Future Improvement
flock
as internal command for the following reasonflock
is slowAtom