On Thu, 09 Dec 2010 12:24:05 -0500, Andrej Mitrovic
On 12/9/10, Steven Schveighoffer <schvei...@yahoo.com> wrote:
__gshared is unprotected sharing, and the type system is not aware that
is shared. Can you remember what specifically you were doing with the
My dev PC is in repairs right now so I don't have the code atm. It's a
project that works with audio devices and does some basic processing
on audio data.
But from what I can recall I would pass my D callback function to C,
which would call the callback with an interrupt or very-high level
priority thread (it depends on the device driver implementation) at
many intervals per second. The D callback would do some processing,
update one structure variable (e.g. struct "status"), and return.
Inside main() I had an infinite loop which would wait for the device
driver to stop calling the callback. One way of knowing if the device
driver stopped is to check a flag inside the struct, e.g. a boolean
Multi-threadded code must do it's own handling of shared reads/writes to
__gshared data, such as protecting it with a mutex. Even with shared, it
does not guarantee multiple operations are atomic (for example reading two
members of a shared struct).