| 115 | // ---------------------------------------------------------------------------------------- |
| 116 | |
| 117 | void threader:: |
| 118 | destruct_if_ready ( |
| 119 | ) |
| 120 | { |
| 121 | if (do_not_ever_destruct) |
| 122 | return; |
| 123 | |
| 124 | data_mutex.lock(); |
| 125 | |
| 126 | // if there aren't any active threads, just maybe some sitting around |
| 127 | // in the pool then just destroy the threader |
| 128 | if (total_count == pool_count) |
| 129 | { |
| 130 | destruct = true; |
| 131 | data_ready.broadcast(); |
| 132 | data_mutex.unlock(); |
| 133 | delete this; |
| 134 | } |
| 135 | else |
| 136 | { |
| 137 | // There are still some user threads running so there isn't |
| 138 | // much we can really do. Just let the program end without |
| 139 | // cleaning up threading resources. |
| 140 | data_mutex.unlock(); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | // ---------------------------------------------------------------------------------------- |
| 145 | |