~unity-system-compositor-team/unity-system-compositor/trunk

« back to all changes in this revision

Viewing changes to tests/unit-tests/advanceable_timer.cpp

  • Committer: Tarmac
  • Author(s): Alexandros Frantzis
  • Date: 2015-07-27 09:29:56 UTC
  • mfrom: (225.2.5 notification-timeouts)
  • Revision ID: tarmac-20150727092956-jt4iczp9jidnu43t
Support different screen timeout values for notifications. Fixes: https://bugs.launchpad.net/bugs/1426115.

Approved by Alan Griffiths, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
std::unique_ptr<mir::time::Alarm> AdvanceableTimer::create_alarm(
124
124
    std::function<void()> const& callback)
125
125
{
126
 
    decltype(now) now_tmp;
127
 
    {
128
 
        std::lock_guard<std::mutex> lock{now_mutex};
129
 
        now_tmp = now;
130
 
    }
131
 
 
132
126
    auto const adv_alarm =
133
 
        std::make_shared<detail::AdvanceableAlarm>(now_tmp, callback);
 
127
        std::make_shared<detail::AdvanceableAlarm>(now(), callback);
134
128
 
135
129
    register_alarm(adv_alarm);
136
130
 
147
141
{
148
142
    {
149
143
        std::lock_guard<std::mutex> lock{now_mutex};
150
 
        now += advance;
 
144
        now_ += advance;
151
145
    }
152
146
    trigger_alarms();
153
147
}
189
183
        if (alarm)
190
184
        {
191
185
            lock.unlock();
192
 
            decltype(now) now_tmp;
193
 
            {
194
 
                std::lock_guard<std::mutex> lock{now_mutex};
195
 
                now_tmp = now;
196
 
            }
197
 
 
198
 
            alarm->update_now(now_tmp);
 
186
            alarm->update_now(now());
199
187
            lock.lock();
200
188
        }
201
189
    }
209
197
            }),
210
198
        end(alarms));
211
199
}
 
200
 
 
201
mir::time::Timestamp AdvanceableTimer::now() const
 
202
{
 
203
    std::lock_guard<std::mutex> lock{now_mutex};
 
204
    return now_;
 
205
}