How does swephgo manage the underlying C TLS variables ?
viskey98 opened this issue · 0 comments
viskey98 commented
Context:
- The C.swe_set_sid_mode call inside swephgo.SetSidMode func basically points to the C implementation of original swiss ephemeris set_sid_mode func (C swiss-ephemeris latest 2.10.3 version src code ref).
- If you check the C implementation it basically sets the sid_mode inside a datastructure variable swed which is stored in TLS (thread local storage).
Problem Statement:
Go uses go-routines to execute a function. Let's say in between while executing the swephgo.SetSidMode func, what if the go-routine switches threads (say from thread_1 to thread_2), the sid_mode set in the TLS of the thread_1 won't be availabel in the thread_2 and the function would not have worked as expected right? Or am I missing something here?
Note: I observe that there is some Mutex lock and unlock happening, but that should still not help in this "go-routine switching" threads issue IMO.