caProvider: Speed up addChannel()
Use wptr::expired() instead of wptr::lock() for testing if the shared pointer is still valid, *much* faster! Also switched from index to interator, but that's incidental.
This commit is contained in:
@ -107,12 +107,12 @@ Channel::shared_pointer CAChannelProvider::createChannel(
|
||||
|
||||
void CAChannelProvider::addChannel(const CAChannelPtr &channel)
|
||||
{
|
||||
std::vector<CAChannelWPtr>::iterator it;
|
||||
epicsGuard<epicsMutex> G(channelListMutex);
|
||||
for (size_t i = 0; i < caChannelList.size(); ++i)
|
||||
for (it = caChannelList.begin(); it != caChannelList.end(); ++it)
|
||||
{
|
||||
if (!(caChannelList[i].lock()))
|
||||
{
|
||||
caChannelList[i] = channel;
|
||||
if (it->expired()) {
|
||||
*it = channel;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user