Create a binding context within a session so binding conveyance works#24
Closed
robhanlon22 wants to merge 6 commits intoaroemers:2.xfrom
Closed
Create a binding context within a session so binding conveyance works#24robhanlon22 wants to merge 6 commits intoaroemers:2.xfrom
robhanlon22 wants to merge 6 commits intoaroemers:2.xfrom
Conversation
9743249 to
aba68f4
Compare
aba68f4 to
2713e26
Compare
robhanlon22
commented
Sep 25, 2020
Comment on lines
+222
to
+232
| `(let [p# (promise)] | ||
| {:thread (doto (Thread. (fn [] | ||
| (.set ^InheritableThreadLocal @#'itl (Thread/currentThread)) | ||
| (try | ||
| (deliver p# (do ~@body)) | ||
| (catch Throwable t# | ||
| (deliver p# t#) | ||
| (throw t#)) | ||
| (finally | ||
| (stop))))) | ||
| (binding [*session* (new-session)] | ||
| (.set ^InheritableThreadLocal itl *session*) | ||
| (try | ||
| (deliver p# (do ~@body)) | ||
| (catch Throwable t# | ||
| (deliver p# t#) | ||
| (throw t#)) | ||
| (finally | ||
| (stop)))))) |
Contributor
Author
There was a problem hiding this comment.
I think that this should be converted to a future, which can be derefed directly and is run within a thread implicitly. However, I didn't want to make a potentially breaking change without checking with you first, @aroemers.
robhanlon22
commented
Sep 25, 2020
|
|
||
| (defn current-session | ||
| [] | ||
| (or (.get ^InheritableThreadLocal itl) *session*)) |
Contributor
Author
There was a problem hiding this comment.
Combining the approaches of using the InheritableThreadLocal and a binding so we can fall back to the *session* if the InheritableThreadLocal's value is missing.
4450a0a to
3ccc5df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #22.