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
9 9
10boost::thread_specific_ptr<int> ptr;10boost::thread_specific_ptr<int> ptr;
11 11
12// https://www.boost.org/doc/libs/1_60_0/libs/context/doc/html/context/context.html12// https://www.boost.org/doc/libs/1_76_0/libs/context/doc/html/context/context.html
13#include <boost/context/all.hpp>13#include <boost/context/fiber_fcontext.hpp>
14boost::context::fcontext_t fcm,fc1,fc2;14namespace ctx=boost::context;
15 15
16void test_thread()16void test_thread()
17{17{
@@ -21,23 +21,6 @@ void test_thread() · 3 unmodified lines
21 std::cout << "Hello, World! from thread" << std::endl;21 std::cout << "Hello, World! from thread" << std::endl;
22}22}
23 23
24void 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
33void 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
41int main(int argc, char *argv[])24int main(int argc, char *argv[])
42{25{
43 (void)argc;26 (void)argc;
@@ -50,15 +33,28 @@ int main(int argc, char *argv[]) · 6 unmodified lines
50 boost::thread thrd(test_thread);33 boost::thread thrd(test_thread);
51 thrd.join();34 thrd.join();
52 35
53 std::size_t size(8192);36 int data=0;
54 void* sp1(std::malloc(size));37 ctx::fiber f1{[&data](ctx::fiber&& f2) {
55 void* sp2(std::malloc(size));38 std::cout << "f1: entered first time: " << data << std::endl;
56 39 data+=1;
57 fc1=boost::context::make_fcontext(sp1,size,f1);40 f2=std::move(f2).resume();
58 fc2=boost::context::make_fcontext(sp2,size,f2);41 std::cout << "f1: entered second time: " << data << std::endl;
59 42 data+=1;
60 std::cout<<"main: call jump_fcontext( & fcm, fc1, 0)"<<std::endl;43 f2=std::move(f2).resume();
61 boost::context::jump_fcontext(&fcm,fc1,0);44 std::cout << "f1: entered third time: " << data << std::endl;
62 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;
63 return 0;59 return 0;
64}60}

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