May 22, 2014 Attach and detach C threads to D runtime | ||||
---|---|---|---|---|
| ||||
Hi, I am currently writing a fuse wrapper for D and try to support fuse multithreading which is based on pthreads. However fuse doesn't offer me a proper way to hook into the creation and joining process of threads. I can attach the threads created by libfuse but cannot find a way to properly detach the threads from the runtime: My current approach: Whenever a fuse function is called I check with a thread local variable "isAttached" if the current thread is already attached, if not, I call thread_attachThis. This works fine and let the GC properly suspend the threads, however when fuse_main() returns all threads are gone but the Druntime still tracks the now non-existant threads anymore. When the GC does a final sweep it will crash. Any ideas how to unregister my threads beforehand. I know that thread_detachByAddr exists, but the Thread object from Thread.getAll or Thread.opApply doesn't expose the thread address. Hints? - Thanks,David |
May 23, 2014 Re: Attach and detach C threads to D runtime | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Soria Parra | On Thursday, 22 May 2014 at 19:21:26 UTC, David Soria Parra via Digitalmars-d-learn wrote:
>
> I know that thread_detachByAddr exists, but the Thread object from
> Thread.getAll or Thread.opApply doesn't expose the thread address.
Would thread_detachThis work for you? Alternately, you can use pthread_self to get the current thread's address on Posix and GetCurrentThreadId on Windows.
|
Copyright © 1999-2021 by the D Language Foundation