381 | | class Worker |
382 | | { |
383 | | public: |
384 | | Worker() : thread(0), stopped(false) {} |
385 | | |
386 | | virtual ~Worker() |
387 | | { |
388 | | { |
389 | | Glib::Mutex::Lock lock (mutex); |
390 | | stopped = true; |
391 | | } |
392 | | if (thread) |
393 | | thread->join(); |
394 | | } |
395 | | |
396 | | void start() |
397 | | { |
398 | | thread = Glib::Thread::create(sigc::mem_fun(*this, &Worker::run), true); |
399 | | } |
400 | | |
401 | | Glib::Dispatcher sig_done; |
402 | | |
403 | | protected: |
404 | | virtual void run() = 0; |
405 | | |
406 | | Glib::Thread* thread; |
407 | | Glib::Mutex mutex; |
408 | | bool stopped; |
409 | | }; |
410 | | }}} |
411 | | }}} |
412 | | |
413 | | Each GUI class which uses threads has a {{{Worker}}} member initially set to null. Then once a function that starts the work is called the worker is created and started, and signal handlers are connected to handle the {{{Dispatcher}}} objects: |
| 381 | class Worker |
| 382 | { |
| 383 | public: |
| 384 | Worker() : |
| 385 | thread(0), |
| 386 | stopped(false) |
| 387 | {} |
| 388 | |
| 389 | virtual ~Worker() |
| 390 | { |
| 391 | { |
| 392 | Glib::Mutex::Lock lock (mutex); |
| 393 | stopped = true; |
| 394 | } |
| 395 | this->join(); |
| 396 | } |
| 397 | |
| 398 | void start() |
| 399 | { |
| 400 | thread = Glib::Thread::create(sigc::mem_fun(*this, &Worker::run), true); |
| 401 | } |
| 402 | |
| 403 | void join() |
| 404 | { |
| 405 | if (thread) |
| 406 | thread->join(); |
| 407 | thread = 0; |
| 408 | } |
| 409 | |
| 410 | Glib::Dispatcher sig_done; |
| 411 | |
| 412 | protected: |
| 413 | virtual void run() = 0; |
| 414 | |
| 415 | Glib::Thread* thread; |
| 416 | Glib::Mutex mutex; |
| 417 | bool stopped; |
| 418 | }; |
| 419 | }}} |
| 420 | }}} |
| 421 | |
| 422 | Each GUI class which uses threads has a {{{Worker}}} member. Then once a function that starts the work is called the worker is started, and signal handlers are connected to handle the {{{Dispatcher}}} objects: |
469 | | Luckily there's not so many any more, however the major one is the memory consumption. This is quite a difficult problem, but it should be looked at before lag can be released to the public. \\ \\ |
470 | | Another one is handling of the LAS 1.3 files, which works, but can be improved (eg. saving to the same file). This may not be possible though as long as laslib just ignores full waveform data. \\ \\ |
471 | | Also there is an issue with rendering/loading thread where forcing ON_EXPOSE event while loading a file at the same time may sometimes cause a segfault. For example moving some window on top of the TwoDeeOverview window while file is being loaded may cause this. This is most likely caused by both loading and rendering thread trying to access the quadtree at the same time and I believe sorting out the rendering thread should solve this problem. |
| 480 | The github project has an [https://github.com/arsf/lag/issues?state=open issues page] currently in use as a rudimentary bug tracker. |