More advise wanted - how to run TWO loops ?
-
Here is the latest snag I am against. Main part of my application is to WAIT to receive data. In fancy techno talk - I have a server in "accept" state - waiting to receive data - hence processing is stopped. The data received is processed and then passed to OpenGL - OpenGL is in similar waiting state "they" call glutMainLoop(); Obviously unworkable situation - cannot have two waiting state. . Found "fork" which creates two processes , but they do not share variables. Looking at socketpair to solve that "problem". Now it looks as proverbial "long way around the barn"... Any other "professional" suggestion ? Not really sure how to debug such setup - jumping between processes , but willing to try it.
-
Here is the latest snag I am against. Main part of my application is to WAIT to receive data. In fancy techno talk - I have a server in "accept" state - waiting to receive data - hence processing is stopped. The data received is processed and then passed to OpenGL - OpenGL is in similar waiting state "they" call glutMainLoop(); Obviously unworkable situation - cannot have two waiting state. . Found "fork" which creates two processes , but they do not share variables. Looking at socketpair to solve that "problem". Now it looks as proverbial "long way around the barn"... Any other "professional" suggestion ? Not really sure how to debug such setup - jumping between processes , but willing to try it.
One word to read up on...
threads
Cheers, Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
Here is the latest snag I am against. Main part of my application is to WAIT to receive data. In fancy techno talk - I have a server in "accept" state - waiting to receive data - hence processing is stopped. The data received is processed and then passed to OpenGL - OpenGL is in similar waiting state "they" call glutMainLoop(); Obviously unworkable situation - cannot have two waiting state. . Found "fork" which creates two processes , but they do not share variables. Looking at socketpair to solve that "problem". Now it looks as proverbial "long way around the barn"... Any other "professional" suggestion ? Not really sure how to debug such setup - jumping between processes , but willing to try it.
-
Here is the latest snag I am against. Main part of my application is to WAIT to receive data. In fancy techno talk - I have a server in "accept" state - waiting to receive data - hence processing is stopped. The data received is processed and then passed to OpenGL - OpenGL is in similar waiting state "they" call glutMainLoop(); Obviously unworkable situation - cannot have two waiting state. . Found "fork" which creates two processes , but they do not share variables. Looking at socketpair to solve that "problem". Now it looks as proverbial "long way around the barn"... Any other "professional" suggestion ? Not really sure how to debug such setup - jumping between processes , but willing to try it.
fork() and signal() - that's what I used in the 1980's and 1990's before POSIX 4 (later POSIX 1a now pthreads and more recently, threads native to C11 and C++11) came into being. This includes sigwait(), sigpause(), sigsuspend(), etc. Some of these work with threads. It might be possible to emulate the functionality of all concurrency primitives with these elements alone. You can look under the POSIX Standard for more information The Open Group Base Specifications Issue 7, 2018 edition[^] There is already a multi-platform Pause-Resume thread framework on this site. That's what landed me on this web site. It's right here Data Processing Thread with the Pause/Resume Functionality[^]
-
Here is the latest snag I am against. Main part of my application is to WAIT to receive data. In fancy techno talk - I have a server in "accept" state - waiting to receive data - hence processing is stopped. The data received is processed and then passed to OpenGL - OpenGL is in similar waiting state "they" call glutMainLoop(); Obviously unworkable situation - cannot have two waiting state. . Found "fork" which creates two processes , but they do not share variables. Looking at socketpair to solve that "problem". Now it looks as proverbial "long way around the barn"... Any other "professional" suggestion ? Not really sure how to debug such setup - jumping between processes , but willing to try it.
-
I would second Peter_in_2780 suggestion. With modern
C++
(assuming you are usingC++
) it is as friendly as shown in the sample code of this page: std::thread::thread - cppreference.com[^].I generally use KISS approach. The task is to have two event "loops" , one monitoring the bluetooth input and the other processing and displaying results. "fork" does the job. Besides - as I continue to build the app it is not pure C++, such as OpenGL is "just" C.
-
I generally use KISS approach. The task is to have two event "loops" , one monitoring the bluetooth input and the other processing and displaying results. "fork" does the job. Besides - as I continue to build the app it is not pure C++, such as OpenGL is "just" C.
-
Here is the latest snag I am against. Main part of my application is to WAIT to receive data. In fancy techno talk - I have a server in "accept" state - waiting to receive data - hence processing is stopped. The data received is processed and then passed to OpenGL - OpenGL is in similar waiting state "they" call glutMainLoop(); Obviously unworkable situation - cannot have two waiting state. . Found "fork" which creates two processes , but they do not share variables. Looking at socketpair to solve that "problem". Now it looks as proverbial "long way around the barn"... Any other "professional" suggestion ? Not really sure how to debug such setup - jumping between processes , but willing to try it.
Follow the directions here:
man pthread_create