简体   繁体   中英

Is it possible to programmatically add an agent as a resource to a resource pool?

What I am trying to do: I want to create an agent in one process and at the end of the process, add it to a resource pool so that another process that can pick it up and process it further. The two processes are not synchronized so the first process may complete and place the new agent into the pool without a second process in progress to seize it again from the pool and process further, or the second process may start first and enter a wait state at the pool waiting for a new agent to be placed into the pool. The pool can also be initialized with a number of agents that the second process can seize without the first process having deposited a new resource into the pool.

What I can see in the documentation:

  1. I do not see any method on the resource pool class to allow adding/removing from the pool. (It seems you only define the capacity and then the engine dynamically new resources if requested up to the defined capacity)
  2. I can possibly use a collection to store and retrieve the agents from, but the built-in queuing for, and re-evaluating when one is added of a pool is very handy (else I have to hook that up myself)

Any suggestions will be highly appreciated

You can only change the capacity of your ResourcePool using myPool.set_Capacity(int) .

If it is larger than the prior capacity, it will add a resource agent for you, else it will remove some.

To add 1 more, call myPool.set_Capacity(myPool.size()+1)

If you need more advanced functionality, you have to create it yourself using your custom, agent-based resource pool (ie code yourself).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM