stuck-waitfor-destruct
|
Last change
on this file since f1cb193 was f1cb193, checked in by Matthew Au-Yeung <mw2auyeu@…>, 2 days ago |
|
cleanup and add tests
|
-
Property mode
set to
100644
|
|
File size:
429 bytes
|
| Line | |
|---|
| 1 | #include <fstream.hfa>
|
|---|
| 2 | #include <thread.hfa>
|
|---|
| 3 |
|
|---|
| 4 | thread Cleaner {};
|
|---|
| 5 |
|
|---|
| 6 | static inline void ^?{} ( Cleaner &mutex this ) {}
|
|---|
| 7 |
|
|---|
| 8 | static inline void cleanup( Cleaner &mutex this ) {}
|
|---|
| 9 |
|
|---|
| 10 | void main( Cleaner & this ) {
|
|---|
| 11 | waitfor( cleanup : this ) {
|
|---|
| 12 | sout | "Cleaning";
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | waitfor( ^?{} : this ) {
|
|---|
| 16 | sout | "Done";
|
|---|
| 17 | }
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | int main() {
|
|---|
| 21 | // Creates a thread that will call the destructor
|
|---|
| 22 | // when the thread exits
|
|---|
| 23 | Cleaner c;
|
|---|
| 24 | cleanup( c );
|
|---|
| 25 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.