comp.lang.ada
 help / color / mirror / Atom feed
* curses and multithreading
@ 2009-08-04 20:43 Lisa Ansellotti
  2009-08-05  8:17 ` Jean-Pierre Rosen
  0 siblings, 1 reply; 3+ messages in thread
From: Lisa Ansellotti @ 2009-08-04 20:43 UTC (permalink / raw)


hi, i'm a newbie in ada.

i'm using curses, and multithreading.
Linux and gnat.

i'm making an application that uses windows (not MS windows).
three windows, one for my inputs, one for the output of the commands (the
input and the output are in the main thread. input is readed, a parses get
the string and write the output on the output window), and a second thread
uses the third window. this thread is independent, it reads the db and
display on its window the results, and uses only its window. 

the problem is this: i need that the secondary thread use the window to
ouput data, and the main thread continuosly get input, elaborate the input
and give the output on its windows (not in the second thread's window).
 
but if i try to do this, the secondary thread stops the input.
in the main thread i do a "get" for input a string, when the secondary
thread do an output on ITS window, the input in the input window is
blocked.

how can i do to make the two threads independently use input/output,
without one block the other thread's i/o?


this is a part of the source.


task DbCheck is
	entry StartRun;
end DbCheck;

	
task body DbCheck is
	begin	
	accept StartRun do
		While ContinueRunning=true loop
			delay 20.0;
			WriteDbMessages;
		end loop;
	end Ciclo;
end DbCheck;

----------------------------------------------
-- Main
----------------------------------------------
begin
.
.
.
.

dbCheck.StartRun	

while XXXXXXX loop
     Terminal_Interface.Curses.Get            
     (win=>winInput,str=>strInput,len=>10,line=>0,column=>0);
     RunCommand(strInput);
end loop;	
	
.
.
.
.
.
.
.
	


-- 

questo articolo e` stato inviato via web dal servizio gratuito 
http://www.newsland.it/news segnala gli abusi ad abuse@newsland.it





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: curses and multithreading
  2009-08-04 20:43 curses and multithreading Lisa Ansellotti
@ 2009-08-05  8:17 ` Jean-Pierre Rosen
  2009-08-05 17:20   ` Lisa Ansellotti
  0 siblings, 1 reply; 3+ messages in thread
From: Jean-Pierre Rosen @ 2009-08-05  8:17 UTC (permalink / raw)


Lisa Ansellotti a �crit :
[...]
> the problem is this: i need that the secondary thread use the window to
> ouput data, and the main thread continuosly get input, elaborate the input
> and give the output on its windows (not in the second thread's window).
>  
> but if i try to do this, the secondary thread stops the input.
> in the main thread i do a "get" for input a string, when the secondary
> thread do an output on ITS window, the input in the input window is
> blocked.
> 
> how can i do to make the two threads independently use input/output,
> without one block the other thread's i/o?
> 
> 
> this is a part of the source.
> 
> 
> task DbCheck is
> 	entry StartRun;
> end DbCheck;
> 
> 	
> task body DbCheck is
> 	begin	
> 	accept StartRun do
> 		While ContinueRunning=true loop
> 			delay 20.0;
> 			WriteDbMessages;
> 		end loop;
> 	end Ciclo;
> end DbCheck;

Here, your loop is *inside* the rendezvous. It means that the caller
(main) will not proceed until the loop is over. You probably meant:
 task body DbCheck is
 	begin	

 	accept StartRun;
        -- Main returns here

	While ContinueRunning=true loop
           delay 20.0;
 	   WriteDbMessages;
 	end loop;
> end DbCheck;

Note that:
1) your code has this problem, but it is not exactly what you describe
2) your code has a syntax error ("end Ciclo" instead of "end StartRun").

Please always provide the *exact code* that shows the problem, to allow
us to be maximally helpful.
-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: curses and multithreading
  2009-08-05  8:17 ` Jean-Pierre Rosen
@ 2009-08-05 17:20   ` Lisa Ansellotti
  0 siblings, 0 replies; 3+ messages in thread
From: Lisa Ansellotti @ 2009-08-05 17:20 UTC (permalink / raw)


> Here, your loop is *inside* the rendezvous. It means that the caller
> (main) will not proceed until the loop is over. You probably meant:
>  task body DbCheck is
>  	begin	

>  	accept StartRun;
>         -- Main returns here

> 	While ContinueRunning=true loop
>            delay 20.0;
>  	   WriteDbMessages;
>  	end loop;
> > end DbCheck;

ok, thanks! now it works, but the cursor is "jumping" between the two
windows :)


> Please always provide the *exact code* that shows the problem, to allow
> us to be maximally helpful.

that was the right code, but i cutted the useless code from my program,
and i made a mistake.

thanks a lot!

-- 

questo articolo e` stato inviato via web dal servizio gratuito 
http://www.newsland.it/news segnala gli abusi ad abuse@newsland.it





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-05 17:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-04 20:43 curses and multithreading Lisa Ansellotti
2009-08-05  8:17 ` Jean-Pierre Rosen
2009-08-05 17:20   ` Lisa Ansellotti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox