Affects Version/s: None
Fix Version/s: Backlog
hi,i have some ideas to improve the agent system:
1.Agent's thread pool must use a custom ThreadFactory to new threads.Set new thread a system name and set it to be daemon.Thread's name would be used for debug or monitor.And set thread to be daemon asking user to shutdown agents explicitly.
2.Beacause agent's thread is daemon,so if a application doesn't use any agents,the thread pool must not started.I think the agent's thread pools should be lazy initialized.
3.I think agent must allow use to define a agent-own thread pool.That thread pool is only used by a agent,not global.just like:
(define a (agent :executor (java.util.concurrent.Executors/newFixedThreadPool 2)))
(set-executor! a (java.util.concurrent.Executors/newFixedThreadPool 2))
And then,a new function to shutdown agent's custom thread pool:
Why do we need a custom thread pool?
First, the default thread pool is global, send use the thread pool
is a fixed size cpus +2, is likely to become the system bottleneck
sometime. Although you can use the send-off, use the cache thread
pool, but in a real world application, I can not use the cache thread
pool, which will introduce the risk of OutOfMemoryError, normally I
like to use a fixed-size thread pool.
Second, the actions which global thread pool execute are from a
variety of agents, the actions are not homogeneous, and can not
maximize the efficient use of the thread pool.
These are my suggestions on agent,thanks for this great language,i enjoy it.