-
(ev/spawn-thread (how to get current thread id?))
(fiber/current) # get id of the fiber? |
Beta Was this translation helpful? Give feedback.
Answered by
sogaiu
Apr 16, 2025
Replies: 1 comment 5 replies
-
I don't really understand what is being asked, but if this is about the task-id that gets reported in a supervisor channel, may be the following code snippets demonstrate how that might be used. thread case [1]: (def tc (ev/thread-chan 10))
(ev/thread (fn []
(setdyn :task-id :id-for-thread-case)
(error :from-thread))
nil : tc)
(def [t-kwd t-val t-id] (ev/take tc))
(pp [:t-kwd t-kwd])
(pp [:t-val t-val])
# `t-id` should show up as `:id-for-thread-case`
(pp [:t-id t-id]) fiber case: (def c (ev/chan 10))
(ev/go (fn []
(setdyn :task-id :id-for-fiber-case)
(error :from-fiber))
nil c)
(def [f-kwd fib f-id] (ev/take c))
(pp [:f-kwd f-kwd])
(pp [:fib fib])
# `f-id` should show up as `:id-for-fiber-case`
(pp [:f-id f-id]) [1] For the thread case, it looks like one can specify a task-id when calling
In the text above, I think (ev/thread main &opt value flags supervisor) So instead of setting the (ev/thread (fn [] (error :hi))
:id-for-thread :t tc) |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't know.
I may be mistaken, but the task-id in this setting is just an arbitrary keyword that a programmer gets to decide on in order to distinguish content that arrives on the supervisor channel [1]. IIUC, there isn't any intrinsic meaning apart from that. It's possible then that the default behavior is for the task-id to be
nil
for cases where a programmer isn't concerned with making certain distinctions.Also, I'm not sure what you are trying to accomplish. May be you could elaborate a bit more on the background for this question?
[1] For example, since the supervisor channel is a parameter to
ev/thread
/ev/go
, it's conceivable that multiple threads or fibers share a common supe…