Re: How to allocate/free memory under @nogc

2020-05-21 Thread Konstantin via Digitalmars-d-learn
On Thursday, 21 May 2020 at 15:09:57 UTC, Steven Schveighoffer wrote: On 5/20/20 10:50 PM, data pulverizer wrote: how do you allocate/free memory without using the garbage collector? Use C malloc and free. Does allocating and freeing memory using `GC.malloc` and `GC.free` avoid D's garbage

How to move from Unique(someClass) to Unique(someInterface)?

2020-05-16 Thread Konstantin via Digitalmars-d-learn
import std.stdio; import automem; import std.experimental.allocator.mallocator : Mallocator; interface IGetInt { @nogc int GetInt(); } class Foo : IGetInt { @nogc int GetInt() { return 42; } } @nogc void main() { auto foo = Unique!(Foo, Mallocator).construct;

Right ways to work without gc without betterC.

2020-05-01 Thread Konstantin via Digitalmars-d-learn
I saw docs for std.experimental.allocator and also had found automem library(https://code.dlang.org/packages/automem) for c++ style memory management via smartpointers. From GC documentation std.experimental.allocator can not be used for: NewExpression Array appending Array

Re: Multithreading in D

2014-10-09 Thread Konstantin via Digitalmars-d-learn
Are you looking for parallel? http://dlang.org/library/std/parallelism/parallel.html I have seen this, but I'm not sure how to use it. Maybe: float[][] maps = new float[#threads][resolution * resolution]; foreach(i, ref elem; parallel(maps)){ elem = generateTerrain(...); } Does this

Multithreading in D

2014-10-08 Thread Konstantin via Digitalmars-d-learn
Hello D-World, I've written a small terraingenerator in D based on the Hill-Algorithm. To generate a terrain I only need to call the method generateTerrain(...) which returns a float-Array containing the height of each pixel (2D Array mapped with a 1D array with length resolution^2).