Exceptions
Poluje na pojemnik dający się bezproblemowo używać w programie wielowątkowym. Musi spełniać następujące parametry:
- template'owy
- nieblokujące dodawanie, złożoność najwyżej O(logN), najlepiej O(1)
- nieblokujące kasowanie, złożoność nahwyżej O(n), najlepiej O(1)
- możliwość iterowania po aktualnym "snapshocie" kolekcji
Czyli coś w rodzaju garbage collector'a z lepszą możliwością iteracji.
- Kuling's blog
- Odpowiedz
- 114 odsłon
- Kuling's blog
- Odpowiedz
- 119 odsłon
Morals About Safe Coding
Moral #4: Always perform unmanaged resource acquisition in the constructor body, never in initializer lists. In other words, either use "resource acquisition is initialization" (thereby avoiding unmanaged resources entirely) or else perform the resource acquisition in the constructor body.
Moral #5: Always clean up unmanaged resource acquisition in local try block handlers within the constructor or destructor body, never in constructor or destructor function try block handlers.
Moral #8: Prefer using "resource acquisition is initialization" to manage resources. Really, really, really. It will save you more headaches than you can probably imagine, including hard-to-see ones, similar to some we've already dissected.
More Exceptional C++, Herb Sutter
- Kuling's blog
- Odpowiedz
- 153 odsłony
- Kuling's blog
- Odpowiedz
- 141 odsłon
Below you can find three methods of writing exception safe code in real world. In the order prefered by author:
- Petru's ScopeGuard
- RAII
- try / catch mess
http://www.ddj.com/cpp/184403758
- Kuling's blog
- Odpowiedz
- 125 odsłon
http://msdn.microsoft.com/en-us/library/swezty51(VS.80).aspx
int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep) { if (code == EXCEPTION_ACCESS_VIOLATION) { return EXCEPTION_EXECUTE_HANDLER; } else { return EXCEPTION_CONTINUE_SEARCH; }; } void test() { __try { *((char *)(NULL)) = 2; } __except(filter(GetExceptionCode(), GetExceptionInformation())) { cout << "wicked :)"; } }
- Kuling's blog
- 1 odpowiedź
- 305 odsłon
_set_se_translator
http://msdn.microsoft.com/en-us/library/5z4bw5h5(VS.80).aspx
/EHa
http://msdn.microsoft.com/en-us/library/1deeycx5(VS.80).aspx
EXCEPTION_ACCESS_VIOLATION
http://msdn.microsoft.com/en-us/library/ms679356(VS.85).aspx
Structured Exception Handling (C++)
http://msdn.microsoft.com/en-us/library/swezty51(VS.80).aspx
- Kuling's blog
- Odpowiedz
- 143 odsłony
http://msdn.microsoft.com/en-us/library/ac9f67ah(VS.80).aspx
- Kuling's blog
- Odpowiedz
- 156 odsłon
- Kuling's blog
- Odpowiedz
- 157 odsłon

