Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #643 (closed wishlist: fixed)

Opened 1 year ago

Last modified 1 year ago

provide a way to register threads not created by Tango

Reported by: CyberShadow Assigned to: sean
Priority: major Milestone: 0.99.2 RC5
Component: Core Functionality Version: 0.99.1 RC4 Keep
Keywords: Cc: thecybershadow@gmail.com

Description

During development of a DLL, I noticed that Tango doesn't allow the user to register threads that aren't created by Tango, but still run D code (e.g. callbacks). This causes several problems - most importantly, if a GC initiates within that thread, Tango crashes (it's unable to get the Thread variable from the thread's TLS which was never initialized), and GC runs started in other threads will not pause this thread. I tried to fix this - first, by trying to make Tango live with the fact that the current thread is "unmanaged" and unregistered, and second, by trying to implement a Thread.registerExternalThread function. Both attempts failed (stack/EIP were corrupted after a GC run), so I just settled with disabling the GC and having a separate thread which manually pauses the unmanaged thread (via Win32 WinAPI), calls the GC, and resumes the unmanaged thread, every 30 seconds.

Attachments

IgnoreExternal.diff (1.2 kB) - added by CyberShadow on 09/23/07 22:44:35.
Failed attempt #1
Thread.RegisterExternal.d (90.4 kB) - added by CyberShadow on 09/23/07 22:45:08.
Failed attempt #2
RegisterExternal.diff (0.9 kB) - added by CyberShadow on 09/23/07 22:47:29.
oops, meant to upload diff, not source

Change History

09/23/07 22:44:35 changed by CyberShadow

  • attachment IgnoreExternal.diff added.

Failed attempt #1

09/23/07 22:45:08 changed by CyberShadow

  • attachment Thread.RegisterExternal.d added.

Failed attempt #2

09/23/07 22:47:29 changed by CyberShadow

  • attachment RegisterExternal.diff added.

oops, meant to upload diff, not source

10/05/07 05:53:35 changed by larsivi

  • status changed from new to closed.
  • resolution set to fixed.

Added in [2624].