Re: is there a way to: import something = app-xyz-classes-something; ?

2021-06-25 Thread frame via Digitalmars-d-learn
On Saturday, 26 June 2021 at 02:19:18 UTC, someone wrote: What I like most of it is that it scales well for big and complex apps while being really flexible ... and neat :) If you pass each file to the compiler like in your script then every naming convention becomes irrelevant because the co

Re: is there a way to: import something = app-xyz-classes-something; ?

2021-06-25 Thread someone via Digitalmars-d-learn
On Monday, 21 June 2021 at 13:29:59 UTC, Steven Schveighoffer wrote: That being said, I strongly recommend just to name the file the same as the module name. Although you made it clear that you do not favor this use-case I am really satisfied with your solution because, at least to me, has

Re: Are D classes proper reference types?

2021-06-25 Thread kinke via Digitalmars-d-learn
On Friday, 25 June 2021 at 17:05:41 UTC, Ola Fosheim Grøstad wrote: Yes, if you don't want to support weak pointers. I think you need two counters if you want to enable the usage of weak pointers. I cannot imagine how weak pointers would work without an ugly extra indirection layer. If we're

Re: Are D classes proper reference types?

2021-06-25 Thread IGotD- via Digitalmars-d-learn
On Friday, 25 June 2021 at 20:22:24 UTC, Ola Fosheim Grøstad wrote: Hm. Not sure if I follow, I think we are talking about stuffing bits into the counter and not the address? Then I misunderstood. If it's a counter it should be fine. But fat pointers are 16 bytes, so quite expensive. Yes

Re: Are D classes proper reference types?

2021-06-25 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Friday, 25 June 2021 at 17:37:13 UTC, IGotD- wrote: You cannot use the most significant bit as it will not work with some 32-bit systems. Linux with a 3G kernel position for example. Better to use the least significant bit as all allocated memory is guaranteed to be aligned. Regardless this

Re: How to call stop from parallel foreach

2021-06-25 Thread jfondren via Digitalmars-d-learn
On Friday, 25 June 2021 at 19:52:23 UTC, seany wrote: On Friday, 25 June 2021 at 19:30:16 UTC, jfondren wrote: On Friday, 25 June 2021 at 19:17:38 UTC, seany wrote: If i use `parallel(...)`it runs. If i use `prTaskPool.parallel(...`, then in the line : `auto prTaskPool = new TaskPool(threadCo

Re: How to call stop from parallel foreach

2021-06-25 Thread seany via Digitalmars-d-learn
On Friday, 25 June 2021 at 19:30:16 UTC, jfondren wrote: On Friday, 25 June 2021 at 19:17:38 UTC, seany wrote: If i use `parallel(...)`it runs. If i use `prTaskPool.parallel(...`, then in the line : `auto prTaskPool = new TaskPool(threadCount);` it hits the error. Please help. parallel() re

Re: How to call stop from parallel foreach

2021-06-25 Thread jfondren via Digitalmars-d-learn
On Friday, 25 June 2021 at 19:17:38 UTC, seany wrote: If i use `parallel(...)`it runs. If i use `prTaskPool.parallel(...`, then in the line : `auto prTaskPool = new TaskPool(threadCount);` it hits the error. Please help. parallel() reuses a single taskPool that's only established once. Your

Re: How to call stop from parallel foreach

2021-06-25 Thread seany via Digitalmars-d-learn
On Friday, 25 June 2021 at 16:37:44 UTC, seany wrote: On Friday, 25 June 2021 at 16:37:06 UTC, seany wrote: On Friday, 25 June 2021 at 15:50:37 UTC, seany wrote: On Friday, 25 June 2021 at 15:16:30 UTC, jfondren wrote: [...] Try : (this version)[https://github.com/naturalmechanics/mwp/tree/

Re: Are D classes proper reference types?

2021-06-25 Thread IGotD- via Digitalmars-d-learn
On Friday, 25 June 2021 at 17:37:13 UTC, IGotD- wrote: You cannot use the most significant bit as it will not work with some 32-bit systems. Linux with a 3G kernel position for example. Better to use the least significant bit as all allocated memory is guaranteed to be aligned. Regardless thi

Re: Are D classes proper reference types?

2021-06-25 Thread IGotD- via Digitalmars-d-learn
On Friday, 25 June 2021 at 07:17:20 UTC, kinke wrote: Wrt. manual non-heap allocations (stack/data segment/emplace etc.), you could e.g. reserve the most significant bit of the counter to denote such instances and prevent them from being free'd (and possibly finalization/destruction too; this w

Re: Are D classes proper reference types?

2021-06-25 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Friday, 25 June 2021 at 07:17:20 UTC, kinke wrote: Wrt. manual non-heap allocations (stack/data segment/emplace etc.), you could e.g. reserve the most significant bit of the counter to denote such instances and prevent them from being free'd (and possibly finalization/destruction too; this w

Re: Are D classes proper reference types?

2021-06-25 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Friday, 25 June 2021 at 07:01:31 UTC, kinke wrote: Well AFAIK it's mandated by the language, so an RC scheme replacing such allocations by heap ones seems like a definite step backwards - it's a useful pattern, and as Stefan pointed out, definitely in use. You could still stack-allocate but

Re: How to call stop from parallel foreach

2021-06-25 Thread seany via Digitalmars-d-learn
On Friday, 25 June 2021 at 15:50:37 UTC, seany wrote: On Friday, 25 June 2021 at 15:16:30 UTC, jfondren wrote: On Friday, 25 June 2021 at 14:44:13 UTC, seany wrote: This particular location does not cause segfault. It is segfaulting down the line in a completely unrelated location... Wait I w

Re: How to call stop from parallel foreach

2021-06-25 Thread seany via Digitalmars-d-learn
On Friday, 25 June 2021 at 16:37:06 UTC, seany wrote: On Friday, 25 June 2021 at 15:50:37 UTC, seany wrote: On Friday, 25 June 2021 at 15:16:30 UTC, jfondren wrote: [...] Try : (this version)[https://github.com/naturalmechanics/mwp/tree/nested-loops] The goal is to parallelize : `calculate

Re: How to call stop from parallel foreach

2021-06-25 Thread seany via Digitalmars-d-learn
On Friday, 25 June 2021 at 15:16:30 UTC, jfondren wrote: On Friday, 25 June 2021 at 14:44:13 UTC, seany wrote: This particular location does not cause segfault. It is segfaulting down the line in a completely unrelated location... Wait I will try to make a MWP. [Here is MWP](https://github.c

Re: How to call stop from parallel foreach

2021-06-25 Thread jfondren via Digitalmars-d-learn
On Friday, 25 June 2021 at 15:16:30 UTC, jfondren wrote: I reckon that there's some other memory error and that the parallelism is unrelated. @safe: ``` source/AI.d(83,23): Error: cannot take address of local `rData` in `@safe` function `main` source/analysisEngine.d(560,20): Error: cannot ta

Re: How to call stop from parallel foreach

2021-06-25 Thread jfondren via Digitalmars-d-learn
On Friday, 25 June 2021 at 14:44:13 UTC, seany wrote: This particular location does not cause segfault. It is segfaulting down the line in a completely unrelated location... Wait I will try to make a MWP. [Here is MWP](https://github.com/naturalmechanics/mwp). Please compile with `dub build

Re: How to call stop from parallel foreach

2021-06-25 Thread seany via Digitalmars-d-learn
On Friday, 25 June 2021 at 15:08:38 UTC, Ali Çehreli wrote: On 6/25/21 7:21 AM, seany wrote: > The code without the parallel foreach works fine. No segfault. That's very common. What I meant is, is the code written in a way to work safely in a parallel foreach loop? (i.e. Is the code "indepen

Re: How to call stop from parallel foreach

2021-06-25 Thread Ali Çehreli via Digitalmars-d-learn
On 6/25/21 7:21 AM, seany wrote: > The code without the parallel foreach works fine. No segfault. That's very common. What I meant is, is the code written in a way to work safely in a parallel foreach loop? (i.e. Is the code "independent"?) (But I assume it is because it's been the common the

Re: How to call stop from parallel foreach

2021-06-25 Thread seany via Digitalmars-d-learn
On Friday, 25 June 2021 at 14:22:25 UTC, seany wrote: On Friday, 25 June 2021 at 14:13:14 UTC, jfondren wrote: On Friday, 25 June 2021 at 13:53:17 UTC, seany wrote: [...] A self-contained and complete example would help a lot, but the likely problem with this code is that you're accessing pn

Re: How to call stop from parallel foreach

2021-06-25 Thread seany via Digitalmars-d-learn
On Friday, 25 June 2021 at 14:13:14 UTC, jfondren wrote: On Friday, 25 June 2021 at 13:53:17 UTC, seany wrote: [...] A self-contained and complete example would help a lot, but the likely problem with this code is that you're accessing pnts[y][x] in the loop, which makes the loop bodies no l

Re: How to call stop from parallel foreach

2021-06-25 Thread seany via Digitalmars-d-learn
On Friday, 25 June 2021 at 14:10:52 UTC, Ali Çehreli wrote: On 6/25/21 6:53 AM, seany wrote: > [...] workUnitSize)) { > [...] Performance is not guaranteed depending on many factors. For example, inserting a writeln() call in the loop would make all threads compete with each other fo

Re: How to call stop from parallel foreach

2021-06-25 Thread jfondren via Digitalmars-d-learn
On Friday, 25 June 2021 at 13:53:17 UTC, seany wrote: I tried this . int[][] pnts ; pnts.length = fld.length; enum threadCount = 2; auto prTaskPool = new TaskPool(threadCount); scope (exit) {

Re: How to call stop from parallel foreach

2021-06-25 Thread Ali Çehreli via Digitalmars-d-learn
On 6/25/21 6:53 AM, seany wrote: > I tried this . > > int[][] pnts ; > pnts.length = fld.length; > > enum threadCount = 2; > auto prTaskPool = new TaskPool(threadCount); > > scope (exit) { > prTaskPool.finish(); > } > >

Re: How to call stop from parallel foreach

2021-06-25 Thread seany via Digitalmars-d-learn
On Friday, 25 June 2021 at 13:53:17 UTC, seany wrote: On Thursday, 24 June 2021 at 21:19:19 UTC, Ali Çehreli wrote: [...] I tried this . int[][] pnts ; pnts.length = fld.length; enum threadCount = 2; auto prTaskPool = new TaskPo

Re: How to call stop from parallel foreach

2021-06-25 Thread seany via Digitalmars-d-learn
On Thursday, 24 June 2021 at 21:19:19 UTC, Ali Çehreli wrote: On 6/24/21 1:41 PM, seany wrote: > Is there any way to control the number of CPU cores used in > parallelization ? Yes. You have to create a task pool explicitly: import std.parallelism; void main() { enum threadCount = 2; auto

Re: How to recursively accept data from Python server ?

2021-06-25 Thread Utk via Digitalmars-d-learn
On Friday, 25 June 2021 at 05:46:54 UTC, Utk wrote: On Friday, 25 June 2021 at 03:27:24 UTC, jfondren wrote: On Friday, 25 June 2021 at 02:55:50 UTC, Utk wrote: Please help me to resolve this issue. Try stracing your program to see exactly what it's doing with the socket, and try std.socket's

Re: Are D classes proper reference types?

2021-06-25 Thread kinke via Digitalmars-d-learn
Wrt. manual non-heap allocations (stack/data segment/emplace etc.), you could e.g. reserve the most significant bit of the counter to denote such instances and prevent them from being free'd (and possibly finalization/destruction too; this would need some more thought I suppose).

Re: Are D classes proper reference types?

2021-06-25 Thread kinke via Digitalmars-d-learn
On Friday, 25 June 2021 at 06:09:17 UTC, Ola Fosheim Grøstad wrote: On Thursday, 24 June 2021 at 07:28:56 UTC, kinke wrote: Yes, class *refs* are always pointers. *scope* classes are deprecated (I don't think I've ever seen one); with `scope c = new Object`, you can have the compiler allocate a