bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multi-threaded output


From: Thomas Dickey
Subject: Re: Multi-threaded output
Date: Mon, 25 Oct 2004 19:16:31 -0400 (EDT)

On Mon, 25 Oct 2004, Steven Seeger wrote:

> I am writing a multi-threaded ncurses program. The user can type in some
> text fields in one window while a timed thread updated values in another
> window. Sometimes the user's input corrupts the screen, however.
>
> I notice that if I draw something and then call abort() the program quits
> without updating the screen. This tells me that the output is not
> synchronous. All curses calls lock a mutex via a macro which I have
> confirmed works correctly. Are there any known issues with multi-threaded
> ncurses?

ncurses isn't thread-safe.  Occasionally someone asks about it, but no
one's done any work to make this happen.

> I did notice that only the calling thread can use getch().

getch does a refresh.  If your other threads are running concurrently
and updating the screen, it won't work.

If you added a mutex to refresh and getch, there's still the places
that would update the screen (a lot of places).  Probably the simplest
way to go would be to add an entrypoint to ncurses that provides the
mutex, use that in blocks of code that would do updates.  That way
you wouldn't be locking/unlocking things down at the character level.

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net




reply via email to

[Prev in Thread] Current Thread [Next in Thread]