Add a lot more documentation to STM and structure it better #302
Conversation
Oh and also: Is there a place in the |
@1Jajen1 need to make some time to go through this, but feel free to restructure the Arrow Fx website a bit to make room for STM in the sidebar. Perhaps we need to relocate https://github.com/arrow-kt/arrow-site/blob/master/docs/_data/sidebar-fx.yml |
Likely as this will apply to I'll try to think of something, but as of now I don't have a good idea what the category for |
We could change the |
No clue how this got in there
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.
Great addition to the docs. Some suggestions, which leads to a bit to duplication but I think that's okay!
Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
At least I think this will fix it ^^
Also use suspend fun main for all examples except the main ones
A second review is needed @arrow-kt/maintainers |
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.
* well distributed the hash function is), it also means that structural changes can be isolated and thus do not increase contention with | ||
* other transactions. This effectively means concurrent access to different values is unlikely to interfere with each other. | ||
* | ||
* > Hash conflicts are resolved by chaining. |
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.
What does it mean by chaining?
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.
There are two ways to to resolve hash conflicts:
- Either replace the value and assume hashes are unique
- Or put them in a collection and iterate through them on lookups
Chaining here refers to chaining it to the end of the leaf array, I've heard and seen it used in this context while I did a bit of research on how Hamt structures work so I just used it here.
* val tq = TQueue.new<Int>() | ||
* atomically { | ||
* tq.write(0) | ||
* tq.filter { it != 0 } |
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.
filter as a name is confusing if it does not return a new queue as users may be used ro. Is there a better name for this op?
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 honestly have no idea, it really does filter, so dunno. Actually I really dislike the filter as an api because it a) increases contention (accesses both TVars) and b) it has a weird/different api as you mentioned.
Maybe it makes sense to just 馃敟 it.
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.
Maybe applyFilter
to highlight that it directly applies to the TQueue
?
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.
If you dislike the function, I am fine with removing it. It can always be re-added later, removing is harder 馃榿
I agree the name is a bit confusing.
Perhaps something along the line of remove
/removeAll
? That's a function found in the Kotlin Standard library but only available for mutable collections.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/remove.html
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/remove-all.html
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 keeping it is fine, removeAll
with a predicate is a really good name. It still has the problem of contention but it may have some actual use, so long as its used infrequently its perfectly fine.
Yes please, now is the perfect time to align the api, I took the names from the haskell libs and related so any change is fine by me. I'll do it in this pr if that is fine with you. |
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'm starting to read the doc ... I'm impressed with the work you have done for Continuations & STM 馃憦 A README explaining the main functionalities would be useful to introduce the purpose of the module. |
Thanks for reading it 馃檹 The README: Regarding the implementation or the api function? I suppose a readme describing how the implementation works ala |
Either way I think its best left for another pr as this one is quite close to completion. For a general introduction to what STM can do the api docs for the |
We don't need a long README: a short introduction would be sufficient, as long as the reader is encouraged to read the STM class doc (I mean it is important to mark the main entry point of the API). |
Ah ok, I was confused by what exactly you were referring to. I'll add that in this pr, thanks for the suggestion! At some point I'll add a section to it which explains the internals as a sort of contribution guide like |
|
Very very simple way of pointing ppl towards to docs
Added a readme which contains a link to the If there is nothing else I'll merge this pr later today 馃帀 |
So after seeing the rendered api docs for STM I wasn't quite satisfied. It was really hard to see which methods worked on which datatype and what the datatypes actually did.
This hopefully addresses that issue by documenting the datatypes with the methods used to operate on them. It also adds a ton of simple examples and changes/adds a few
operator
overload methods to be more like the stdlib collections.Edit: This is 95-99% documentation btw^^ So don't be scared by
+2000
here 馃檲