Jump to content

Emil Mustea

Members
  • Content Count

    12
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Emil Mustea


  1. 12 hours ago, Tom F said:

    Mostly on-topic question: how is it that commercial remote control programs (Zoom, GotoMyPC, WebEx) seem to be able to get around most firewalls without help from IT?

    These programs first they try a direct connection - if the port is not blocked it works, if it's blocked and the router/firewall is UPnP, it adds an inbound rule which grants exterior access only for the lifetime of the program. Don't expect your company router to be UPnP enabled.

    If direct connection doesn't succeed then third-party server owned by TeamViewer/GotoMyPC/WebEx/etc is used as a middle man forwarding messages between those 2 parties, but usually works with direct connection.

     

    Establishing connection is not the hard part, having a very good real-time algorithm for capturing/transferring images/mouse without flicker/lag from one party to another is the hard part.

    • Thanks 1

  2. To summarize:

     

    Who wants maximum performance like "classic" use it like this

    var obj := Shared.Make(TTestObj.Create)();

    "obj" is object and will be free it at the end of the procedure;

     

    otherwise, use it:

    var obj := Shared.Make(TTestObj.Create);

    "obj" is interface and will be free it at the end of the block and every access has a small penalty of an anonymous method call.

    • Like 4

  3. 31 minutes ago, Rudy Velthuis said:

    That should be

     

    
    begin 
      var s := New.Of(TStringList.Create);

    Note that Of could be an error (keyword), although as New.Of it might compile. You could give TAutoFreeRecord a class function returning an instance of the record:


     

    
    begin
      var S := TAutoFreeRecord.New(TStringList.Create); // returns TStringList instance

     

    1. I get to used with inline declaration 🙂

    2. You wrote "instance of a record" - in this case we need member lifting. If TAutoFreeRecord returns generic type of that parameter, then it's like the example I gave.


  4. I think if we use copy constructor we can create smart pointers like this:

    procedure DoSomething(OtherParameters: string; New: TAutoFreeRecord); //here "New" record is created by copy constructor 
    var
        s: TStrings;
    begin
        s := New.Of(TStringList.Create);
        s.Add('one');
        s.Add('two');
        //here "New" goes out of scope and will destroy "s" (custom destructor)
    end;

    or with inline declaration:

     

    procedure DoSomething(OtherParameters: string; New: TAutoFreeRecord); //here "New" record is created by copy constructor
    begin
        s := New.Of(TStringList.Create);
        s.Add('one');
        s.Add('two');
        //here "New" goes out of scope and will destroy "s" (custom destructor)
    end;

    It was very nice if managed records in 10.3 had member lifting. In that way we could escape declaring "New"; New.Of will return instead a record which the only member could be lifted and used as a TStrings.


  5. 2 hours ago, Cristian Peța said:

    Perhaps that New record must also be declared next to s1. Otherwise how can it go out of scope? 

    Sorry, it's my mistake. I forgot the "var": (inline declaration with type inference)

    begin
    	var sl := New.Of(TStringList.Create);
       	sl.Add("One");
       	sl.Add("Two");
       	//here the record "New" goes out of scope, runs the it's destructor which will free the instance on which "sl" points to
    end;

     

    1 hour ago, Cristian Peța said:

    A record without a reference will stay alive up to routine end?  I must test this.

    ....

    Just verified in Lazarus and suppose it's similar in Delphi.

    That record lives on stack up to the routine end.

    Better: with inline declaration will stay alive until the block end, not until routine end.

    • Like 1

  6. On 10/26/2018 at 12:58 PM, Marco Cantu said:

    On top of this, we want to improve and simplify the management of the lifetime (and memory management) of local short-lived objects with stack references. This is a not feature we are going to introduce in 10.3, but something we are actively investigating and can be partially implemented by developers leveraging managed records (a new language feature in 10.3).

    quote from: http://blog.marcocantu.com/blog/2018-october-Delphi-ARC-directions.html

     

    If "managed records" from 10.3 have destructor like I understand, there is no need for default property/member lifting. Will be possible super cool (and readable) construct like this:

    begin
    	sl := New.Of(TStringList.Create);
       	sl.Add("One");
       	sl.Add("Two");
       	//here the record "New" goes out of scope, runs the it's destructor which will free the instance on which "sl" points to
    end;

    I hope I'm not missing something.

     

    Mr. Marco Cantu, can you confirm the "managed records" from 10.3 have destructor?


  7. 4 hours ago, Stefan Glienke said:

    Now it would be cool if on a record type you could specify a property as default so it does member lifting in order to get rid of having to type .Value when accessing the underlying value. Especially when the record does not have any other members anyway. That would indeed make records even more powerful as they are already.

    The quote is from:  https://delphisorcery.blogspot.com/2015/01/smart-pointers-in-delphi.html

     

    Can somebody confirm that the "new" record type will have a default property? so will not have to write .Value in smart pointers. Indeed this will be really cool and really useful as automatic memory management:

     

    var
      s: Shared<TStrings>;
    begin
      s := TStringList.Create;
      s.Add('one');
      s.Add('two');
      //here "s" will be realeased automatically because is a record
    end;

     

×