go to start Ex W10
|home |print view |recent changes |changed May 4, 2018 |
exact
|You are 54.92.160.119 <- set your identity!

Sections: Threading in C++ on Windows | Extended RAII Wrapper | TESTAT-3: BoundedQueue with timed operations | Extra (Not part of the testat): Lock-free implementation of BoundedQueue |

Threading in C++ on Windows ^

Iff you encounter problems with threads not being supported by your compiler:

The MinGW-w64 compiler should work if you install it with posix threading model: https://sourceforge.net/projects/mingw-w64/

Extended RAII Wrapper ^

This is a repetition exercise for variadic forwarding templates. In the lecture you have seen Anythony Williams' suggestion for a scoped_thread. The wrapper is always constructed from an rvalue thread. Wouldn't it be nice to be able to create the scoped_thread from a function and the call arguments directly?

scoped_thread st{<function>, [<arguments>]};

Instead of

scoped_thread st{std::thread{<function>, [<arguments>]}};

TESTAT-3: BoundedQueue with timed operations ^

Due date: Monday 21.05.2018 23:59 CEST Subject: [C++A-testat-3] hsrname1 hsrname2 hsrname3

Write a BoundedQueue<T> template class that provides the functions

Use the mechanisms from your BoundedBuffer to allow move-only and non-default-constructible template argument types. You can also copy parts of the code and add the required synchronization.

Anthony Williams gives the following advice for testing multi-threaded bounded queue:

Use the mechanisms from your BoundedBuffer to allow move-only and non-default-constructible template argument types. You can also copy parts of the code and add the required synchronization.

Tests provided: https:files/BoundedQueueTestsW11.zip

or on github

Please also answer the following questions when handing in your header file:

  1. Why can't we use the front() and back() member functions from BoundedBuffer?
  2. Why doesn't it make sense to provide iterators for BoundedQueue?
    • Can you suggest an alternative means for observing the BoundedQueue content?
  3. Why is pop() returning a value by value and not void as in BoundedBuffer?

Extra (Not part of the testat): Lock-free implementation of BoundedQueue ^

If you are eager, try to figure out, if there is the possibility to implement a BoundedQueue just relying on atomics for synchronization. Be aware of the ABA problem. Would that be faster?


|home |print view |recent changes |changed May 4, 2018 |
exact
|You are 54.92.160.119 <- set your identity!

Ex W10
go to start