| 50 | bool failure; |
| 51 | |
| 52 | void thread_write () |
| 53 | { |
| 54 | // do this so that the readonly threads can get into their loops first. This way |
| 55 | // we can see if the mutex lets many readers into their area |
| 56 | dlib::sleep(250); |
| 57 | for (int i = 0; i < 6; ++i) |
| 58 | { |
| 59 | auto_mutex lock(m); |
| 60 | |
| 61 | mut.lock(); |
| 62 | ++num_write; |
| 63 | mut.unlock(); |
| 64 | |
| 65 | // only one write thread should ever be active at once |
| 66 | if (num_write != 1) |
| 67 | { |
| 68 | failure = true; |
| 69 | dlog << LERROR << "1"; |
| 70 | } |
| 71 | |
| 72 | dlib::sleep(300); |
| 73 | |
| 74 | // only one write thread should ever be active at once |
| 75 | if (num_write != 1) |
| 76 | { |
| 77 | failure = true; |
| 78 | dlog << LERROR << "2"; |
| 79 | } |
| 80 | |
| 81 | mut.lock(); |
| 82 | --num_write; |
| 83 | mut.unlock(); |
| 84 | |
| 85 | print_spinner(); |
| 86 | } |
| 87 | dlog << LINFO << "exit thread_write()"; |
| 88 | } |
| 89 | |
| 90 | void do_readonly_stuff() |
| 91 | { |
nothing calls this directly
no test coverage detected