/** * Execute poll on this device: create an array of messages, add them to the request queue, and * schedule the queue for processing. * * @param delay scheduling delay (in milliseconds) */ public void doPoll(long delay) { long now = System.currentTimeMillis(); ArrayList<QEntry> l = new ArrayList<QEntry>(); synchronized (m_features) { int spacing = 0; for (DeviceFeature i : m_features.values()) { if (i.hasListeners()) { Msg m = i.makePollMsg(); if (m != null) l.add(new QEntry(i, m, now + delay + spacing)); } spacing += TIME_BETWEEN_POLL_MESSAGES; } } if (l.isEmpty()) return; synchronized (m_requestQueue) { for (QEntry e : l) { m_requestQueue.add(e); } } RequestQueueManager.s_instance().addQueue(this, now + delay); if (!l.isEmpty()) { synchronized (m_lastTimePolled) { m_lastTimePolled = now; } } }