On Friday, 10 November 2017 at 13:50:56 UTC, rikki cattermole wrote:
Remember this bit: Everything on the heap, is not thread-local, it is global. This includes everything inside a class.

When you synchronize (statement) it is locking and then unlocking a mutex. A class has a mutex, simple! It only prevent multiple threads modifying a single thing at specific times, thats all.

this is my implementation of Accept


private void Accept(){
        // start accepting in a different thread
        try{
            _client = _server.accept();
emit(ClientConnected(_client.remoteAddress.toAddrString));
            auto _acceptTask = task(&this.Accept);
            _acceptTask.executeInNewThread();
            Receive();
        }
        catch (SocketAcceptException e){
            writeln("Error while accepting connection: " ~ e.msg);
        }
    }

Is _client on the Heap or the Stack? If it is on the Stack, how would i get in on the Heap?

Reply via email to