-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
37 lines (28 loc) · 662 Bytes
/
main.cpp
File metadata and controls
37 lines (28 loc) · 662 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// main.cpp
// queued_thread_control
//
// Created by Christopher Goebel on 6/9/19.
// Copyright © 2019 Christopher Goebel. All rights reserved.
//
#include "ThreadSafeQueue.hpp"
#include <iostream>
#include <thread>
int main(int argc, const char * argv[]) {
locked_opt_queue<long> counter_queue;
std::thread{
[&](){
while (true) {
auto item = counter_queue.get();
if (not item) {
break;
}
std::cout << *item << '\n'; // call print queue here
}
std::cout << "done thread\n";
}
}.detach();
counter_queue.push(1333);
counter_queue.join();
printf("abc\n");
}