Hi Arkadiusz,

> 27 jan 2015 kl. 15:21 skrev Arkadiusz Burdach <arek.burd...@gmail.com>:
> 
> Hi Konrad,
> Thanks for reply. More inlined.
> 
> W dniu wtorek, 27 stycznia 2015 11:01:58 UTC+1 użytkownik Konrad Malawski 
> napisał:
> Please do not ever rely on java finalization – ever.
> 
> For one thing, it's unreliable – no-one guarantees that these will ever be 
> called. [60] 
> <https://github.com/arkadius/akka-simple/blob/master/src/main/scala/akka/actor/simple/SimpleActor.scala#L60>
> Also, just by having a finalizer defined you put a way larger burden on the 
> collector as it has to track those in a similar way it does with 
> java.lang.ref.* references (putting in reference queues etc instead of just 
> reclaiming space).
> It's true. In fact this finalize behaviour was only a hint for Actor. I could 
> provide other way to clenup internal actors for example repeated job checking 
> if SimpleActor was released. And also it is in't a core thing for this 
> implementation to cleanup an internal Actor. Core memory part will be 
> declared in SimpleActors which will be normally cleaned up by jvm.

No matter how you implement this, it will always involve either WeakReference 
or finalizers, both of which are the devil. There is no other way—if there were 
then we’d already implemented this :-)

> 
>  
> You should never block in your Actors when working with Akka. Remember the 
> "never block" mantra :-)
> Calling Await inside actor code is a big "no-no" – this will cause your 
> entire application (everyone on that dispatcher) to suffer for it. [36] 
> <https://github.com/arkadius/akka-simple/blob/master/src/main/scala/akka/actor/simple/SimpleActor.scala#L36>
> Please refer to the documentation about actor systems 
> <http://doc.akka.io/docs/akka/snapshot/general/actor-systems.html#actor-best-practices>
>  to read more about this.
> Yes, I know this. Shortcut for Await was only added for purpose of quicker 
> Actor tests and it is minor think. I know that the best is to keep your code 
> as much async as it possible. But I think that it could be helpful to just 
> check how Actor will reply on request without using additional tools like 
> Await.
> 
>  
> In general I would not recommend wrapping Akka in such way and simply 
> embracing the asynchronous nature of it.
> You'll get better performance and fully-embracing these concepts instead of 
> hiding it here and there will get you to cleaner code by the end of the day 
> too.
> Ok, but what do you think about shortcut for creating Actors by new operator 
> with auto-gc? I don't think about it as a subistitution but just like a nice 
> addition :-) I think that in many cases people use akka actors for small 
> applications that will be never used in cluster. For this simple use case it 
> is a little inconvenience to declare ActorSystem, provide specialized 
> ExecutionContext depend on situation, and keep thinking if actors memory was 
> released.
> I know background of all this things but tools should be selected depend on 
> situation :-)

Auto-GC comes at too big a cost, but the main reason I would recommend against 
this approach is that supervision is neglected: by only being able to create 
top-level actors most of the advantages of the Actor model are removed.

If you are after a smaller syntax footprint you might want to check out the 
ActorDSL 
<https://github.com/akka/akka/blob/v2.3.9/akka-actor/src/main/scala/akka/actor/ActorDSL.scala>
 which uses an implicit ActorRefFactory for creation. It has been provided for 
quickly sketching actor programs in the Scala REPL.

Regards,

Roland

> 
> Cheers,
> Arek
> 
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/>
> >>>>>>>>>> Check the FAQ: 
> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html>
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user 
> >>>>>>>>>> <https://groups.google.com/group/akka-user>
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to akka-user+unsubscr...@googlegroups.com 
> <mailto:akka-user+unsubscr...@googlegroups.com>.
> To post to this group, send email to akka-user@googlegroups.com 
> <mailto:akka-user@googlegroups.com>.
> Visit this group at http://groups.google.com/group/akka-user 
> <http://groups.google.com/group/akka-user>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.



Dr. Roland Kuhn
Akka Tech Lead
Typesafe <http://typesafe.com/> – Reactive apps on the JVM.
twitter: @rolandkuhn
 <http://twitter.com/#!/rolandkuhn>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to