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:
Andrew Johnson
2021-10-01 09:32:11 -05:00
parent 75e3d9e114
commit 671f5a406c

View File

@ -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;
}
}