public abstract class AbstractDeviceTracker implements DeviceTracker {
10
private volatile DeviceList deviceList;
11
private final AtomicBoolean updatePending = new AtomicBoolean();
12
13
public AbstractDeviceTracker(final DeviceList deviceList) {
14
this.deviceList = deviceList;
15
}
16
17
protected abstract boolean isUpdateRequested();
18
19
protected abstract void discardUpdateRequest();
20
21
@Override
22
public DeviceList currentDevices() {
23
return this.deviceList;
24
}
25
26
@Override
27
public void forceRefresh() {
28
this.discardUpdateRequest();
29
this.deviceList = DeviceList.query();
30
}
31
32
@Override
33
public void tick() {
34
if (this.isUpdateRequested()) {
35
this.discardUpdateRequest();
36
if (this.updatePending.compareAndSet(false, true)) {
37
Util.ioPool().execute(() -> {
38
this.deviceList = DeviceList.query();
39
this.updatePending.set(false);
40
});
41
}
42
}
43
}
44
}
45
Decompiled Minecraft 26.3 source of AbstractDeviceTracker (com/mojang/blaze3d/audio/AbstractDeviceTracker.java) with Mojang official mappings, stored verbatim on the site.