Using the Poco C ++ library, how can I transfer data to a stream?

So my question has several parts:

Using the Poco Threading Library:

  • What are all the possible methods of transferring data to streams (both when calling a stream, and for an already running stream).
  • What methods are preferable to you and why? Can you provide more information about your experience using these methods?
  • What methods are recommended by Applied Informatics (author of Poco)? Is there any additional documentation provided by Applied Informatics that describes passing arguments to threads?

I already looked here:

Thanks in advance...

+6
source share
1 answer

The canonical way to pass arguments to a new thread is through the Runnable subclass, which you need to create as a stream entry point. Example:

class MyThread: public Poco::Runnable { public: MyThread(const std::string& arg1, int arg2): _arg1(arg1), _arg2(arg2) { } void run() { // use _arg1 and _arg2; //... } private: std::string _arg1; int _arg2; }; //... MyThread myThread("foo", 42); Poco::Thread thread; thread.start(myThread); thread.join(); 

To transfer data to an already running stream, the best solution depends on your requirements. For a typical workflow scenario, consider using Poco :: NotificationQueue . A full sample with explanations can be found here: http://pocoproject.org/slides/090-NotificationsEvents.pdf

+15
source

Source: https://habr.com/ru/post/921352/


All Articles