From 17c7ac8157c7794a823e7132ac185bf1d05cb8ed Mon Sep 17 00:00:00 2001 From: hugbgithub Date: Fri, 25 Dec 2015 22:57:04 +0800 Subject: [PATCH 1/2] add watch list for mesos --- mesos_note/watch.list | 1 + 1 file changed, 1 insertion(+) create mode 100644 mesos_note/watch.list diff --git a/mesos_note/watch.list b/mesos_note/watch.list new file mode 100644 index 0000000..6217e96 --- /dev/null +++ b/mesos_note/watch.list @@ -0,0 +1 @@ +https://issues.apache.org/jira/browse/MESOS-2145 From c01f159ea4e85cc83001095f7690ab2231f9d8df Mon Sep 17 00:00:00 2001 From: hugbgithub Date: Wed, 2 Mar 2016 16:20:08 +0800 Subject: [PATCH 2/2] excep.cpp demonstrate stack unwind when throw exception, only automatic variables will be reclaimed --- excep.cpp | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 excep.cpp diff --git a/excep.cpp b/excep.cpp new file mode 100644 index 0000000..bf541a0 --- /dev/null +++ b/excep.cpp @@ -0,0 +1,84 @@ +#include +#include +#include +#include + +using namespace std; + +class MyException{}; +class Dummy +{ + public: + Dummy(string s) : MyName(s) { PrintMsg("Created Dummy:"); } + Dummy(const Dummy& other) : MyName(other.MyName){ PrintMsg("Copy created Dummy:"); } + ~Dummy(){ PrintMsg("Destroyed Dummy:"); } + void PrintMsg(string s) { cout << s << MyName << endl; } + string MyName; + int level; +}; + + +void C(Dummy d, int i) +{ + cout << "Entering FunctionC" << endl; + d.MyName = " C"; + throw MyException(); + + cout << "Exiting FunctionC" << endl; +} + +void B(Dummy d, int i) +{ + cout << "Entering FunctionB" << endl; + d.MyName = "B"; + C(d, i + 1); + cout << "Exiting FunctionB" << endl; +} + +void A(Dummy d, int i) +{ + cout << "Entering FunctionA" << endl; + d.MyName = " A" ; + //Dummy* pd = new Dummy("new Dummy"); //Not exception safe!!! + tr1::shared_ptr sp(new Dummy("new Dummy")); + B(d, i + 1); + //delete pd; + cout << "Exiting FunctionA" << endl; +} + + +int main() +{ + cout << "Entering main" << endl; + try + { + Dummy d(" M"); + A(d,1); + } + catch (MyException& e) + { + cout << "Caught an exception of type: " << typeid(e).name() << endl; + } + + cout << "Exiting main." << endl; + char c; + cin >> c; +} + +/* Output: + Entering main + Created Dummy: M + Copy created Dummy: M + Entering FunctionA + Copy created Dummy: A + Entering FunctionB + Copy created Dummy: B + Entering FunctionC + Destroyed Dummy: C + Destroyed Dummy: B + Destroyed Dummy: A + Destroyed Dummy: M + Caught an exception of type: class MyException + Exiting main. + +*/