logo       

Re: Race Conditions: msg#00024

Subject: Re: Race Conditions
--- edward barlow <barlowedward@xxxxxxxxxxx> wrote:

> I appear to be getting a race condition in Perl/Tk. 
> I click on a user 
> interface element (a button) which redraws a
> Tk::Tree and then click on 
> another button quickly (before the first element
> finishes the tree redraw) 
> that also will cause a tree redraw.  From what i can
> tell,  I end up 
> redrawing the tree twice simultaneously...  I end up
> with duplicate elements 
> and getting an error.  Clicking slowly produces no
> errors..  Is this normal 
> under a multi threaded version perl and is there a
> way to force Tk events to 
> be single threaded...

Tk is not thread safe. Your description is a bit
vague, but I'm assuming that the Tk stuff all happens
in the same thread. If that is the case, then you can
do two options (assuming I understand your query):

1) Have a global variable, something like $treeRedraw,
being set to 1 at the beginning of each function that
repopulates your Tree, and reset to 0 at the end. Then
your functions will only execute if $treeRedraw is set
to 0.

or

2) When the first button is clicked, the first thing
it does is disable the second button, and only enable
it at the end of the function. And vice versa.

Theoretically, you can still get a race condition, but
you'll need to drink a loooot of coffee to be able to
press the two buttons simultaneously with a single
mouse!

--Ala



                
__________________________________ 
Do you Yahoo!? 
The all-new My Yahoo! - Get yours free! 
http://my.yahoo.com 
 

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@xxxxxxxxxxxxxxxxxx



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qnx.openqnx.dev...    politics.lenini...    audio.emagic.ex...    tex.texinfo.gen...    handhelds.linux...    ietf.sipping/20...    lang.erlang.gen...    cygwin.talk/200...    yellowdog.gener...    mozilla.devel.l...    xfree86.newbie/...    openbsd.ports/2...    db.oracle.devel...    kde.kalyxo.deve...    user-groups.lin...    bbc.cvs/2003-04...    gnu.libtool.bug...    redhat.k12osn/2...    emulators.wine....    freebsd.devel.d...    search.xapian.g...    java.izpack.use...    network.mrtg.us...    windows.total-c...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe