On Tuesday, May 31, 2016 at 4:44:17 PM UTC, Páll Haraldsson wrote:
>
> On Monday, May 30, 2016 at 8:19:34 PM UTC, Tobias Knopp wrote:
>>
>> If you are prepared to make your code to not perform any heap 
>> allocations, I don't see a reason why there should be any issue. When I 
>> once worked on a very first multi-threading version of Julia I wrote 
>> exactly such functions that won't trigger gc since the later was not thread 
>> safe. This can be hard work but I would assume that its at least not more 
>> work than implementing the application in C/C++ (assuming that you have 
>> some Julia experience)
>>
>
> I would really like to know why the work is hard, is it getting rid of the 
> allocations, or being sure there are no more hidden in your code? I would 
> also like to know then if you can do the same as in D language:
>
> http://wiki.dlang.org/Memory_Management
>
 

> that is would it be possible to make a macro @nogc and mark functions in a 
> similar way?
>

The @nogc macro was made a long time ago, I now see:

https://groups.google.com/forum/?fromgroups=#!searchin/julia-users/Suspending$20Garbage$20Collection$20for$20Performance...good$20idea$20or$20bad$20idea$3F/julia-users/6_XvoLBzN60/nkB30SwmdHQJ

I'm not saying disabling the GC is preferred, just that the macro has been 
done to do it had already been done.

Karpinski has his own exception variant a little down the thread with "you 
really want to put a try-catch around it". I just changed that variant so 
it can be called recursively (and disabled try-catch as it was broken):

macro nogc(ex)
         quote
           #try
             local pref = gc_enable(false)
             local val = $(esc(ex))
           #finally
             gc_enable(pref)
           #end
           val
         end
       end


Reply via email to