Project

General

Profile

Actions

Support #2176

closed
VV WD

Emit signal from another thread to Wt main thread with parameters

Support #2176: Emit signal from another thread to Wt main thread with parameters

Added by Vitaly Volochay about 13 years ago. Updated about 13 years ago.

Status:
Closed
Priority:
Urgent
Assignee:
Target version:
Start date:
09/04/2013
Due date:
% Done:

0%

Estimated time:

Description

Hello! As far as I know I can't use Wt signal/slots system outside Wt main thread because WApplication::instance doesn't exist in other threads. So I need somehow pass data from another thread to my widget. I need something similar to PostedSignal from http://redmine.webtoolkit.eu/boards/1/topics/5182 but with parameters.

If Wt signal/slots system works outside main thread it will looks like this:

/* main gui class */
class SomeCustomWidget: public WContainerWidget
{
...

void onDataChanged(int value);

Controller* ctrl;
};

SomeCustomWidget::SomeCustomWidget()
{
...
ctrl->dataChanged().connect(this, &SomeCustomWidget::onDataChanged);
}

/* ctrl live in another thread */
class Controller
{
...
Wt::Signal& dataChanged();
};

What is the best way to solve my problem?

WD Updated by Wim Dumon about 13 years ago Actions #1

call post in combination with boost::bind.

Wt::WServer::instance()->post(sessionId, boost::bind(myFunction, myParameter));

where m_myFunction is a function accepting one parameter.

BR,
Wim.

KD Updated by Koen Deforche about 13 years ago Actions #2

  • Status changed from New to InProgress
  • Assignee set to Wim Dumon

VV Updated by Vitaly Volochay about 13 years ago Actions #3

Thanks, I solve my problem.

WD Updated by Wim Dumon about 13 years ago Actions #4

  • Status changed from InProgress to Closed
Actions

Also available in: PDF Atom