libc: implement threads for libcxx
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
#include <iostream>
|
||||
#include <cerrno>
|
||||
#include <fcntl.h>
|
||||
#include <thread>
|
||||
|
||||
int main() {
|
||||
std::vector<int> items;
|
||||
items.push_back(1);
|
||||
items.push_back(2);
|
||||
items.push_back(3);
|
||||
std::cout << "Spawning a thread" << std::endl;
|
||||
std::cout << "Main thread is: " << std::this_thread::get_id() << std::endl;
|
||||
std::cout << "Hardware concurrency: " << std::thread::hardware_concurrency() << std::endl;
|
||||
|
||||
for (const auto &item: items) {
|
||||
std::cout << "Item: " << item << std::endl;
|
||||
}
|
||||
std::thread t1([]() {
|
||||
std::cout << "Hello from a thread!!!" << std::endl;
|
||||
std::cout << "This is thread: " << std::this_thread::get_id() << std::endl;
|
||||
});
|
||||
|
||||
std::cout << "&errno = " << &errno << std::endl;
|
||||
std::cout << "errno = " << errno << std::endl;
|
||||
open("/xxxsaa", 0, 0);
|
||||
std::cout << "errno = " << errno << std::endl;
|
||||
std::cout << "Waiting for a thread" << std::endl;
|
||||
t1.join();
|
||||
std::cout << "Thread finished" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user