Returns the next "ready to use" channel from the given pool.
This function returns the next "ready to use" channel from the given pool. Because a vortex channel pool may have no channel ready to be used the function could return NULL. But you can also make this function to add a new channel to the pool if no channel is ready by using auto_inc as TRUE.
The channel returned can be used for any operation even close the channel. But, before issuing a close operation over a channel which already belongs to a pool this channel must be detached from the pool using vortex_channel_pool_deattach.
In general a close operation over channels belonging to a pool is not recommended. In fact, the need to avoid channel closing operation was the main reason to produce the vortex_channel_pool module because as we have said the channel close operation is too expensive.
It's a better approach to let the vortex connection destruction function to close all channels created for a pool. Actually the vortex connection destroy function close and destroy all channel pool created over a given connection.
Another recommendation to keep in mind is the startup problem. Due to the initial requirement to create new channels for the pool on the first connections it may slow down the startup giving a sense of slow link connection. A good approach is to create a pool with one channel and use this function with the auto_inc set always to TRUE.
This will enforce to create new channels only when needed reducing the performance impact of creating an arbitrary number of channels (inside the pool) at the startup. Of course this is only a recommendation.
|pool ||the pool where the channel will be get. |
|auto_inc ||instruct this function to create a new channel if not channel is ready to be used.k|
- the next channel ready to use or NULL if fails. Note NULL may also be returned even setting auto_inc to TRUE.