History

update boost to 1.78.0

Fixes #2550.

Orgad Shaneh committed 5 years ago

Commit 0b1a63b1 parent 33423af5 files · +44 −633Browse files

Showing the changes to src/boost-test.cpp (1 of 5 files). Show all

Unified · Split

src/boost-test.cpp+26−30
@@ -9,9 +9,9 @@ · 8 unmodified lines
99
1010 boost::thread_specific_ptr<int> ptr;
1111
12−// https://www.boost.org/doc/libs/1_60_0/libs/context/doc/html/context/context.html
13−#include <boost/context/all.hpp>
14−boost::context::fcontext_t fcm,fc1,fc2;
12+// https://www.boost.org/doc/libs/1_76_0/libs/context/doc/html/context/context.html
13+#include <boost/context/fiber_fcontext.hpp>
14+namespace ctx=boost::context;
1515
1616 void test_thread()
1717 {
@@ -21,23 +21,6 @@ void test_thread() · 3 unmodified lines
2121 std::cout << "Hello, World! from thread" << std::endl;
2222 }
2323
24−void f1(intptr_t)
25−{
26− std::cout<<"f1: entered"<<std::endl;
27− std::cout<<"f1: call jump_fcontext( & fc1, fc2, 0)"<< std::endl;
28− boost::context::jump_fcontext(&fc1,fc2,0);
29− std::cout<<"f1: return"<<std::endl;
30− boost::context::jump_fcontext(&fc1,fcm,0);
31−}
32−
33−void f2(intptr_t)
34−{
35− std::cout<<"f2: entered"<<std::endl;
36− std::cout<<"f2: call jump_fcontext( & fc2, fc1, 0)"<<std::endl;
37− boost::context::jump_fcontext(&fc2,fc1,0);
38− BOOST_ASSERT(false&&!"f2: never returns");
39−}
40−
4124 int main(int argc, char *argv[])
4225 {
4326 (void)argc;
@@ -50,15 +33,28 @@ int main(int argc, char *argv[]) · 6 unmodified lines
5033 boost::thread thrd(test_thread);
5134 thrd.join();
5235
53− std::size_t size(8192);
54− void* sp1(std::malloc(size));
55− void* sp2(std::malloc(size));
56−
57− fc1=boost::context::make_fcontext(sp1,size,f1);
58− fc2=boost::context::make_fcontext(sp2,size,f2);
59−
60− std::cout<<"main: call jump_fcontext( & fcm, fc1, 0)"<<std::endl;
61− boost::context::jump_fcontext(&fcm,fc1,0);
62−
36+ int data=0;
37+ ctx::fiber f1{[&data](ctx::fiber&& f2) {
38+ std::cout << "f1: entered first time: " << data << std::endl;
39+ data+=1;
40+ f2=std::move(f2).resume();
41+ std::cout << "f1: entered second time: " << data << std::endl;
42+ data+=1;
43+ f2=std::move(f2).resume();
44+ std::cout << "f1: entered third time: " << data << std::endl;
45+ return std::move(f2);
46+ }};
47+ f1=std::move(f1).resume();
48+ std::cout << "f1: returned first time: " << data << std::endl;
49+ data+=1;
50+ f1=std::move(f1).resume();
51+ std::cout << "f1: returned second time: " << data << std::endl;
52+ data+=1;
53+ f1=std::move(f1).resume_with([&data](ctx::fiber&& f2){
54+ std::cout << "f2: entered: " << data << std::endl;
55+ data=-1;
56+ return std::move(f2);
57+ });
58+ std::cout << "f1: returned third time" << std::endl;
6359 return 0;
6460 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t