The previous implementation has a timing issue. This patch is to fix the issue.
The main thread calls WaitAndPop() method and the thread calls Push() method.
Change-Id: Id4b19b6fee1c31f2ebd8bed16dbc782161c3c8e5
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
TEST(SharedQueueTest, PushAndWaitAndPop) {
tizen_base::SharedQueue<Job> queue;
std::thread thread([&] {
- auto job = queue.WaitAndPop();
+ Job job;
job.Do();
queue.Push(std::move(job));
});
- queue.Push(Job());
- usleep(100);
auto job = queue.WaitAndPop();
thread.join();