-
Notifications
You must be signed in to change notification settings - Fork 8
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
Create a binding context within a session so binding conveyance works #24
base: 2.x
Are you sure you want to change the base?
Conversation
9743249
to
aba68f4
Compare
aba68f4
to
2713e26
Compare
src/mount/lite.clj
Outdated
`(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)))))) |
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 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.
|
||
(defn current-session | ||
[] | ||
(or (.get ^InheritableThreadLocal itl) *session*)) |
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.
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
Resolves #22.