Summary
Is there any way to detect if a non-legato thread has already been initialized?
Issue
I am using Go
so all concurrency is performed via Goroutines, as such the runtime routine scheduler handles thread lifetimes. This makes registering threads that use legato api’s a challenge. I have found a work around for Goroutines directly launched by me via the below:
go func() {
runtime.LockOSThread()
tname := C.CString("sig_monitoring_thread")
C.le_thread_InitLegatoThreadData(tname)
defer C.le_thread_CleanupLegatoThreadData()
C.free(unsafe.Pointer(tname))
C.le_mrc_ConnectService()
//le_,rc can be used now
}()
This does not account for my code being launched by a Goroutine from another framework. I originally tried to just call le_thread_InitLegatoThreadData
more often, but I found that if this is called by a thread that is already registered, legato kills the process.
Right now I am hoping there is a way to detect if a thread is registered to legato and only if it is not, call le_thread_InitLegatoThreadData
. If you have another strategy, i am also open to it (short of recompiling go with legato baked in).