wxWidgets and IOs with select/poll/epoll

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

wxWidgets and IOs with select/poll/epoll

Guy Morand
Hi wxWidgets users!

I'm giving a first try to wxWidgets and would like to handle events from a "select" like loop (serial port).

My first idea was to implement a separated thread to handle all IOs and communicate with the main thread following this page:
https://wiki.wxwidgets.org/Inter-Thread_and_Inter-Process_communication

Am I on the right track or is there a more elegant way to handle this using the existing main loop?

Best regards,

Guy 

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|

Re: wxWidgets and IOs with select/poll/epoll

Vadim Zeitlin-4
On Mon, 1 Oct 2018 12:33:13 -0700 (PDT) Guy Morand wrote:

GM> I'm giving a first try to wxWidgets and would like to handle events from a
GM> "select" like loop (serial port).
GM>
GM> My first idea was to implement a separated thread to handle all IOs and
GM> communicate with the main thread following this page:
GM> https://wiki.wxwidgets.org/Inter-Thread_and_Inter-Process_communication
GM>
GM> Am I on the right track or is there a more elegant way to handle this using
GM> the existing main loop?

 Using a separate thread works and is probably quite sufficient for working
with the serial port, which is not going to require anything amazing from
the performance point of view. Under Unix, you could also use
wxEventLoop::AddSourceForFD() to register your file descriptor directly
with the main event loop. This might be a more typical way to do things
under Unix but it makes your code unportable to MSW.

 Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: wxWidgets and IOs with select/poll/epoll

Guy Morand
Thanks for the pointer, this is the kind of event loop I was looking
for! After some though running my own in background should be the
easiest and thread synchronization is fun ;p!

All the best,

Guy

On 10/2/18 1:45 AM, Vadim Zeitlin wrote:

> On Mon, 1 Oct 2018 12:33:13 -0700 (PDT) Guy Morand wrote:
>
> GM> I'm giving a first try to wxWidgets and would like to handle events from a
> GM> "select" like loop (serial port).
> GM>
> GM> My first idea was to implement a separated thread to handle all IOs and
> GM> communicate with the main thread following this page:
> GM> https://wiki.wxwidgets.org/Inter-Thread_and_Inter-Process_communication
> GM>
> GM> Am I on the right track or is there a more elegant way to handle this using
> GM> the existing main loop?
>
>   Using a separate thread works and is probably quite sufficient for working
> with the serial port, which is not going to require anything amazing from
> the performance point of view. Under Unix, you could also use
> wxEventLoop::AddSourceForFD() to register your file descriptor directly
> with the main event loop. This might be a more typical way to do things
> under Unix but it makes your code unportable to MSW.
>
>   Regards,
> VZ
>

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users