~ubuntu-branches/ubuntu/utopic/mir/utopic-proposed

« back to all changes in this revision

Viewing changes to src/server/compositor/switching_bundle.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-03-10 19:28:46 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: package-import@ubuntu.com-20140310192846-rq9qm3ec26yrelo2
Tags: upstream-0.1.6+14.04.20140310
ImportĀ upstreamĀ versionĀ 0.1.6+14.04.20140310

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
    }
91
91
}
92
92
 
 
93
mc::SwitchingBundle::~SwitchingBundle() noexcept
 
94
{
 
95
    force_requests_to_complete();
 
96
}
 
97
 
93
98
int mc::SwitchingBundle::nfree() const
94
99
{
95
100
    return nbuffers - ncompositors - nready - nclients;
180
185
void mc::SwitchingBundle::client_acquire(std::function<void(graphics::Buffer* buffer)> complete)
181
186
{
182
187
    std::unique_lock<std::mutex> lock(guard);
 
188
    client_acquire_todo = std::move(complete);
183
189
 
184
190
    if ((framedropping || force_drop) && nbuffers > 1)
185
191
    {
210
216
            1;
211
217
#endif
212
218
 
213
 
        while (nfree() < min_free)
214
 
            cond.wait(lock);
 
219
        if (nfree() < min_free)
 
220
            return;
215
221
    }
216
222
 
 
223
    complete_client_acquire(std::move(lock));
 
224
}
 
225
 
 
226
void mc::SwitchingBundle::complete_client_acquire(std::unique_lock<std::mutex> lock)
 
227
{
 
228
    auto complete = std::move(client_acquire_todo);
 
229
 
217
230
    if (force_drop > 0)
218
231
        force_drop--;
219
232
 
247
260
        ring[client].buf = ret;
248
261
    }
249
262
 
250
 
    complete(ret.get());
 
263
    lock.unlock();
 
264
 
 
265
    try
 
266
    {
 
267
        complete(ret.get());
 
268
    }
 
269
    catch (...)
 
270
    {
 
271
        // TODO comms errors should not propagate to compositing threads
 
272
    }
251
273
}
252
274
 
253
275
void mc::SwitchingBundle::client_release(graphics::Buffer* released_buffer)
339
361
            first_compositor = next(first_compositor);
340
362
            ncompositors--;
341
363
        }
342
 
        cond.notify_all();
 
364
 
 
365
        if (client_acquire_todo) complete_client_acquire(std::move(lock));
343
366
    }
344
367
}
345
368
 
392
415
void mc::SwitchingBundle::force_requests_to_complete()
393
416
{
394
417
    std::unique_lock<std::mutex> lock(guard);
395
 
    drop_frames(nready);
396
 
    force_drop = nbuffers + 1;
397
 
    cond.notify_all();
 
418
    if (client_acquire_todo)
 
419
    {
 
420
        drop_frames(nready);
 
421
        force_drop = nbuffers + 1;
 
422
        complete_client_acquire(std::move(lock));
 
423
    }
398
424
}
399
425
 
400
426
void mc::SwitchingBundle::allow_framedropping(bool allow_dropping)