How to specify --arch option in dub.json
I use dub 1.2.1 to build my project. As convenience, I choose `dflags-windows-x86: ["-m32mscoff"]` option in dub.json of my library binding to specify default architecture in win32 platform. But in the newest dub release, this cause a warning which told me to use DLFAGS environment or specify arch in command line. Is there any other ways to fix this for I don't want users of this library always build with a long command line args?
Re: Fiber cross threads terminated
On Friday, 2 September 2016 at 01:53:58 UTC, Steven Schveighoffer wrote: On 9/1/16 9:27 PM, mogu wrote: Here's my code in main function: ``` auto fiber = new Fiber({ while (true) { Thread.sleep(1.seconds); Fiber.yield; } }); void foo() { while (true) { fiber.call; //Thread.sleep(1.seconds); //"---".writeln; } } new Thread({ foo(); }).start; new Thread({ Thread.sleep(500.msecs); foo(); }).start; ``` If I comment the `fiber.call;`, all works. system: ubuntu 16.04LTS dmd version: 2.071.1 Fibers in D are not meant to be run in multiple threads. -Steve Thanks. I got it.
Fiber cross threads terminated
Here's my code in main function: ``` auto fiber = new Fiber({ while (true) { Thread.sleep(1.seconds); Fiber.yield; } }); void foo() { while (true) { fiber.call; //Thread.sleep(1.seconds); //"---".writeln; } } new Thread({ foo(); }).start; new Thread({ Thread.sleep(500.msecs); foo(); }).start; ``` If I comment the `fiber.call;`, all works. system: ubuntu 16.04LTS dmd version: 2.071.1
Re: About spinlock implementation
On Thursday, 1 September 2016 at 07:46:04 UTC, qznc wrote: This effectively makes the access to the protected value unprotected and nullifies the effect of the spinlock. So the cas operation implicit an MemoryOrder.acq? Does it make any other MemoryOrder guarantee?
Re: About spinlock implementation
On Thursday, 1 September 2016 at 07:46:04 UTC, qznc wrote: I'm not sure I understand rel [0], but raw is too weak. Raw means no sequencing barrier, so local_var = protected_value; spinlock.unlock(); could be transformed (by compiler or CPU) to spinlock.unlock(); local_var = protected_value; This effectively makes the access to the protected value unprotected and nullifies the effect of the spinlock. I find the documentation on MemoryOrder lacking about the semantics of rel. :( [0] https://dlang.org/library/core/atomic/memory_order.html Thanks very much. I finally got it. :)
About spinlock implementation
I found an implementation of spinlock in concurrency.d. ``` static shared struct SpinLock { void lock() { while (!cas(&locked, false, true)) { Thread.yield(); } } void unlock() { atomicStore!(MemoryOrder.rel)(locked, false); } bool locked; } ``` Why atomicStore use MemoryOrder.rel instead of MemoryOrder.raw?
Re: Prevent copy of range in foreach
On Tuesday, 30 August 2016 at 19:06:46 UTC, Yuxuan Shui wrote: Is there a way to use a range defined with disabled post-blit in foreach? In other words, is there a way to prevent foreach from copying the range? Should I use move()? 国人?望加群:531010036 谢谢
Re: compile error while use `extern(C++, class)`
On Thursday, 18 August 2016 at 16:41:27 UTC, Lodovico Giaretta wrote: On Thursday, 18 August 2016 at 16:19:41 UTC, Johan Engelen wrote: On Thursday, 18 August 2016 at 11:43:03 UTC, Lodovico Giaretta wrote: Which compiler version are you using? On DMD 2.071.0 this does not work. Note: this does work with LDC 1.1.0 even though it is based on DMD 2.071. https://github.com/ldc-developers/ldc/releases/tag/v1.1.0-beta2 Well, LDC 1.1.0 is based on DMD 2.071.1, while I tested the above code on asm.dlang.org with DMD 2.071.0, so maybe on DMD 2.071.1 it works too. On nightly it works for sure. So again nothing wrong here, just a matter of having the most recent compiler version. No, i'm using the newest version of dmd/ldc2 (2.071.1/1.0.0) released.
Re: compile error while use `extern(C++, class)`
On Thursday, 18 August 2016 at 10:45:14 UTC, Lodovico Giaretta wrote: Which kind of error? An error message by the compiler? One by the linker? The compiler crashes? Compiler Error exactly. The minimal code is(dmd or ldc2 in ubuntu 16.04 lts): ``` extern (C++, struct) class A {} ``` Error: identifier expected for C++ namespace found 'struct' when expecting ')' declaration expected, not ')'
compile error while use `extern(C++, class)`
From spec (Interfacing to C++) https://dlang.org/spec/cpp_interface.html: ``` When mapping a D class onto a C++ struct, use extern(C++, struct) to avoid linking problems with C++ compilers (notably MSVC) that distinguish between C++'s class and struct when mangling. Conversely, use extern(C++, class) to map a D struct onto a C++ class. ``` But this compiles error. Please help, thanks.
Re: Why typeof(template) is void?
On Wednesday, 20 July 2016 at 08:01:01 UTC, Lodovico Giaretta wrote: Note that void is a type, while S is not. So you can do: assert(is(void)) // is(type) returns true assert(!is(S)) // is(template) returns false; Thanks very much. I should have noticed this before. T.T
Re: Why typeof(template) is void?
On Wednesday, 20 July 2016 at 01:50:37 UTC, Adam D. Ruppe wrote: On Wednesday, 20 July 2016 at 01:14:05 UTC, mogu wrote: Why S's type isn't something like `S: (T) -> S`? Because S isn't a type... think of a template as being like a function that returns a type. int foo(int) { return 0; } There, you wouldn't expect typeof(foo) to be int, no, typeof(foo) is a function that returns an int. The template is the same thing - it isn't a type, it is a template that returns a type. So it's a higher kinded type aka type class in Haskell. But D's reflection cannot get enough information about template's kind. Only a `void` given. It may be inconvenient in distinction between an alias of template and void. The only solution AFAIK is by string of the type property .stringof.
Why typeof(template) is void?
``` struct S(T) {} static assert(is (typeof(S) == void)); ``` Why S's type isn't something like `S: (T) -> S`?