-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add callback getter. add examples. bug fix.
- Loading branch information
Showing
26 changed files
with
428 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// Created by Levalup. | ||
// L.eval: Let programmer get rid of only work jobs. | ||
// | ||
|
||
#include <iostream> | ||
#include <chrono> | ||
|
||
#include "uvcxx/barrier.h" | ||
#include "uvcxx/thread.h" | ||
#include "uvcxx/utilities.h" | ||
|
||
int main() { | ||
uv::barrier_t barrier(2); | ||
auto beg = std::chrono::steady_clock::now(); | ||
|
||
uv::thread_t thread1([&barrier, beg]() { | ||
std::cout << uvcxx::catstr("thread-1 wait ", 0, "ms\n") << std::flush; | ||
barrier.wait(); | ||
auto end = std::chrono::steady_clock::now(); | ||
auto spent = std::chrono::duration_cast<std::chrono::milliseconds>(end - beg).count(); | ||
std::cout << uvcxx::catstr("thread-1 exit after ", spent, "ms\n") << std::flush; | ||
}); | ||
|
||
uv::thread_t thread2([&barrier, beg]() { | ||
std::cout << uvcxx::catstr("thread-2 wait ", 100, "ms\n") << std::flush; | ||
uv::sleep(100); | ||
barrier.wait(); | ||
auto end = std::chrono::steady_clock::now(); | ||
auto spent = std::chrono::duration_cast<std::chrono::milliseconds>(end - beg).count(); | ||
std::cout << uvcxx::catstr("thread-2 exit after ", spent, "ms\n") << std::flush; | ||
}); | ||
|
||
thread1.join(); | ||
thread2.join(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.