Cross-Platform Programming with wxWidgets
Just Make It Cross-Platform
Subscribe to Feed
  • Home
  • Projects
  • Links

Archive for May, 2008

wxJSON 0.5.0 Released

News No Comments » |

This wxJSON release adds support for 64-bits integers on those platforms that have native support for it such as, for example, Windows and GNU/Linux.

You can disable 64-bits integer support if you do not need (or do not want) it. The new version is compatible wih the past: if you do not need 64-bits integers you can still use this new version of the library without the need to rewrite your application.

To know more about the new feature read the this page:

  • wxJSON website
  • wxJSON detailed documentation:
  • wxCode project website
  • Download wxJSON
  • JSON offical site

May 12th, 2008 |

Tags: News, wxJSON, wxWidgets




Реализация Job Queue на wxWidgets (+исходник)

Components, wxWidgets No Comments » |

При работе с потоками часто приходится делать кучу однотипных задач: создавать класс, производный от wxThread, реализовывать метод Entry() для этого класса, синхронизацию с главным потоком и т.д.

Eran, автор CodeLite IDE поделился кодом класса JobQueue, который реализует пул потоков и позволяет выполнять задачи в фоновом режиме.

class MyJob : public Job {
public:
        MyJob(){}
        ~MyJob(){}

        // Implement your processing code here
        void Process() {
                wxPrintf(wxT("Just doing my work...n"));
        };
};

// define some custom job with progress report
class MyJobWithProgress : public Job {
public:
        MyJobWithProgress(wxEvtHandler *parent) : Job(parent){}
        ~MyJobWithProgress(){}

        // Implement your processing code here
        void Process() {
                // report to parent that we are at stage 0
                Post(0, wxT("Stage Zero"));
                // do the work
                wxPrintf(wxT("Just doing my work...n"));
                // report to parent that we are at stage 1
                Post(1, wxT("Stage Zero Completed!"));
        };
};

// somewhere in your code, start the JobQueue
// for the demo we use pool of size 5
JobQueueSingleton::Instance()->Start(5);

// whenever you want to process MyJob(), just create new instance of MyJob() and add it to the JobQueue
JobQueueSingleton::Instance()->AddJob( new MyJob() );

// at shutdown stop the job queue and release all its resources
JobQueueSingleton::Instance()->Stop();
JobQueueSingleton::Release();

// OR, you can use JobQueue directly without the JobQueueSingleton wrapper class
// so you could have multiple instances of JobQueue

Главный поток получает уведомления таким вот образом:

// in the event table
EVT_COMMAND(wxID_ANY, wxEVT_CMD_JOB_STATUS, MyFrame::OnJobStatus)

void MyFrame::OnJobStatus(wxCommandEvent &e)
{
    wxString msg;
    msg << wxT("Job progress: Stage: ") << e.GetInt() << wxT(" Message: ") << e.GetString();
    wxLogMessage(msg)
}

Скачать исходный код
Читать обсуждение на wxForum


May 10th, 2008 |

Tags: Components, wxThread, wxWidgets, Статьи




  • This blog is about…

    Articles Code::Blocks Components Controls Database DatabaseLayer Document/View Eclipse Localization NetBeans Networking News Printing Reports SQLite Tutorilas Video Visual Studio wxAUI wxButton wxDev-CPP wxGrid wxHelpController wxJavaScript wxJSON wxLocale wxLog wxPaintDC wxPropertyGrid wxRuby wxSQLite3 wxThread wxValidator wxWidgets wxWinCE wxZipInputStream wxZipOutputStream XML Библиотека Книги Статьи
  • Showcase

    Visit wxToolBox Homepage

    Buy wxToolBox (with source code)

  • Archives

    • November 2009
    • September 2009
    • August 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • December 2007
    • June 2007
    • May 2007
    • January 2007
  • Recent Comments

    • T-Rex on Getting Acquainted with Document/View Framework – Simple Image Viewer
    • T-Rex on Сделайте мне красиво – Часть II – wxAUI в Multi-View приложений
    • Mardiko on Getting Acquainted with Document/View Framework – Simple Image Viewer
    • marty on Сделайте мне красиво – Часть II – wxAUI в Multi-View приложений
    • T-Rex on Перевод книги Julian’а Smart’а – Глава VI – Обработка данных с устройств ввода
  • Buttons

    Locations of visitors to this page

    Rambler's Top100
    Рейтинг@Mail.ru

Copyright © 2010 Cross-Platform Programming with wxWidgets All Rights Reserved
RSS Log in