shared and cryptic error messages

Jose Armando Garcia jsancio at gmail.com
Thu Mar 31 16:33:37 PDT 2011


On Thu, Mar 31, 2011 at 7:59 PM, Jason House
<jason.james.house at gmail.com> wrote:
> Jose Armando Garcia Wrote:
>
>> On Wed, Mar 30, 2011 at 9:39 PM, Jason House
>> <jason.james.house at gmail.com> wrote:
>> > Jose Armando Garcia Wrote:
>> >
>> >> How do I get around this error?
>> >
>> > That's not easy to answer...  To get the compiler to shut up, you can copy and paste FILE's destructor and mark it as shared.  Of course, every method call to your file will similarly required shared methods.  If you make no copies of the file object, and all accesses are from within your synchronized methods, you can probably cast away shared while making the method calls.  Of course, the common theme here is that you're verifying the multi-threaded safety of all this stuff along the way.  If you're not comfortable doing that, then you probably want to do another design that you can prove works.
>> >
>> >
>>
>> This is a great suggestion and that is what I do in my implementation
>> of the synchronized class but I can't cast away the call to the dtor.
>> That call is done by the compiler. I am going to look into __gshared.
>
> For one, definitely file a bug report!
>
> You might be able to mark your FILE as __gshared or make it a pointer. As a pointer, you manage the lifetime, and can cast away shared before calling delete, clear, or whatever.
>
> If file is using TLS globals, or is otherwise unsafe to use the way you want, then you need messages passing.
>
>

I'll file a bug report when I get back to my computer and I can verify
that my memory is not failing me.

>> >> Has anyone tried to write a
>> >> multithreaded application using D?
>> >
>> > Yes, and even succeeded :)
>> >
>>
>> Which? And it it cannot be named what does it do? How many lines of code?
>>
>
> It was an open source hobby project called housebot. I don't have the LOC handy, but it is a program to play the game of go. It has a shared search tree and a hash tree filled with weak pointers. Control messages are done through message passing. Message passing did not exist in Phobos when I wrote it, and I had to take atomic increment code from Tango.
>
>

Thanks!


More information about the Digitalmars-d mailing list