Re: Socket and spawn()

2024-06-02 Thread Andy Valencia via Digitalmars-d-learn
On Sunday, 2 June 2024 at 17:46:09 UTC, bauss wrote: If anything you should use a thread pool that each handles a set of sockets, instead of each thread being a single socket. Yup, thread pool it is. I'm still fleshing out the data structure which manages the incoming work presented to the p

Re: Socket and spawn()

2024-06-02 Thread bauss via Digitalmars-d-learn
On Friday, 31 May 2024 at 16:07:23 UTC, Andy Valencia wrote: I'm coding a server which takes TCP connections. I end up in the main thread with .accept() which hands me a Socket. I'd like to hand this off to a spawn()'ed thread to do the actual work. Aliases to mutable thread-local data

Re: Socket and spawn()

2024-05-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 31, 2024 6:28:27 PM MDT Andy Valencia via Digitalmars-d-learn wrote: > On Friday, 31 May 2024 at 16:59:08 UTC, Jonathan M Davis wrote: > > Speaking as an old kernel engineer for the Sequent multiprocessor > product line, this is all very comfortable to me. I'm very glad > that D ha

Re: Socket and spawn()

2024-05-31 Thread Andy Valencia via Digitalmars-d-learn
On Friday, 31 May 2024 at 16:59:08 UTC, Jonathan M Davis wrote: Strictly speaking, unless you're dealing with a module or static-level variable, the object is not in TLS. It's treated as thread-local by the type system, and the type system will assume that no other thread has access to it, but

Re: Socket and spawn()

2024-05-31 Thread Andy Valencia via Digitalmars-d-learn
On Friday, 31 May 2024 at 19:48:37 UTC, kdevel wrote: Have you taken into consideration that each of the (pre-spawned) threads can call accept()? Your program may also accept in multiple processes on the same socket. [1] Yes, but I am planning on some global behavior--mostly concerning resour

Re: Socket and spawn()

2024-05-31 Thread kdevel via Digitalmars-d-learn
On Friday, 31 May 2024 at 16:07:23 UTC, Andy Valencia wrote: I'm coding a server which takes TCP connections. I end up in the main thread with .accept() which hands me a Socket. I'd like to hand this off to a spawn()'ed thread to do the actual work. Have you taken into consideration that ea

Re: Socket and spawn()

2024-05-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 31, 2024 10:07:23 AM MDT Andy Valencia via Digitalmars-d-learn wrote: > I'm coding a server which takes TCP connections. I end up in the > main thread with .accept() which hands me a Socket. I'd like to > hand this off to a spawn()'ed thread to do the actual work. > > Aliases

Socket and spawn()

2024-05-31 Thread Andy Valencia via Digitalmars-d-learn
I'm coding a server which takes TCP connections. I end up in the main thread with .accept() which hands me a Socket. I'd like to hand this off to a spawn()'ed thread to do the actual work. Aliases to mutable thread-local data not allowed. Is there some standard way to get something which