Skip to content

Commit 0f666e1

Browse files
committed
PVA client searches: Comment the dual data structures
.. and let next search drop channels from the `search_buckets` list
1 parent c1d8b05 commit 0f666e1

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

core/pva/src/main/java/org/epics/pva/client/ChannelSearch.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,20 @@ private class SearchedChannel
9898
}
9999
}
100100

101+
// SearchedChannels are tracked in two data structures
102+
//
103+
// - searched_channels (concurrent)
104+
// Fast lookup of channel by ID,
105+
// efficient `computeIfAbsent(cid, ..` mechanism for creating
106+
// at most one SearchedChannel per CID.
107+
// Allows checking if a channel is indeed searched,
108+
// and locating the channel for a search reply.
109+
//
110+
// - search_buckets (need to SYNC)
111+
// Efficiently schedule the search messages for all channels
112+
// up to MAX_SEARCH_PERIOD.
113+
101114
/** Map of searched channels by channel ID */
102-
// TODO Remove, just use search_buckets?
103115
private ConcurrentHashMap<Integer, SearchedChannel> searched_channels = new ConcurrentHashMap<>();
104116

105117
/** Search buckets
@@ -241,12 +253,10 @@ public PVAChannel unregister(final int channel_id)
241253
if (searched != null)
242254
{
243255
logger.log(Level.FINE, () -> "Unregister search for " + searched.channel.getName() + " " + channel_id);
244-
245-
synchronized (search_buckets)
246-
{
247-
for (LinkedList<SearchedChannel> bucket : search_buckets)
248-
bucket.remove(searched);
249-
}
256+
// NOT removing `searched` from all `search_buckets`.
257+
// Removal would be a slow, linear operation.
258+
// `runSearches()` will drop the channel from `search_buckets`
259+
// because it's no longer listed in `searched_channels`
250260

251261
return searched.channel;
252262
}

0 commit comments

Comments
 (0)