Re: sigx synchronous requests?
- From: klaus triendl <klaus triendl eu>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: sigx synchronous requests?
- Date: Wed, 08 Apr 2009 23:55:26 +0200
Milosz Derezynski schrieb:
Hey everyone, and especially Klaus,
I was wondering if there is a way to have synchronous (that is, achieved
by proper internal locking) requests on sigx threadables?
I have the problem that currently I have a threadable class but I need
one specific synchronous call that immediately returns and passes a direct
return value.
I can achieve this probably by doing some manual locking and so on, but
I would prefer to do it with sigx directly if possible.
There is a way for synchronous requests: open_sync_tunnel() and
open_sync_tunnel_with().
Since there's no direct way to express synchronous requests like
sigx::request_f<> offers for async ones you have to write your own
request wrapper function like so:
<code>
class mythread: public sigx::threadable
{
protected:
// request handler
int on_calc() { return 0; }
public:
// request api
int sync_calc();
};
int mythread::sync_calc()
{
// sync request
return sigx::open_sync_tunnel(
sigc::mem_fun(this, &mythread::on_calc)
);
}
</code>
I don't know exactly anymore why I didn't provide a sync_request_f<>
wrapper, I guess the design rational was that it's not needed very often
and that it's anyway better to use async requests.
Regards,
Klaus
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]