Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
callbacks / recursion limit
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Walter Roberson  
View profile  
 More options Jan 14 2008, 6:01 pm
Newsgroups: comp.soft-sys.matlab
From: rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Date: Mon, 14 Jan 2008 23:01:55 +0000 (UTC)
Local: Mon, Jan 14 2008 6:01 pm
Subject: callbacks / recursion limit
I have a callback tied to a slider, and the callback takes a noticable
time to execute. If I hold down the mouse button on the slider arrow,
events are repeatedly generated, triggering the callback a number
of times. Eventually, Matlab complains that I have hit the recursion
limit. But I haven't actually hit a -recursion- limit as the
callback is not recursive: it's just being queued many times.

I could increase the recursion limit but probably the same thing
would still happen. So what I'd like to know is whether there is
a way I can limit the number of pending events? I know one can
set events to be interrupt or queued; I am using the default (queued)
which is not in itself a problem; the question would be more one of
whether I can limit the queue size ?

If not then what I'll probably have to do is enable/disable
the slider itself; that's probably not going to lead to the best
user experience, but it should solve the queue depth problem.
--
   "History is a pile of debris"                     -- Laurie Anderson


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matthias Fruehwirth  
View profile  
 More options Jan 15 2008, 6:24 am
Newsgroups: comp.soft-sys.matlab
From: Matthias Fruehwirth <matthias.fruehwi...@joanneum.at>
Date: Tue, 15 Jan 2008 12:24:14 +0100
Local: Tues, Jan 15 2008 6:24 am
Subject: Re: callbacks / recursion limit
On Mon, 14 Jan 2008 23:01:55 +0000 (UTC)

rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote:
> I have a callback tied to a slider, and the callback takes a noticable
> time to execute. If I hold down the mouse button on the slider arrow,
> events are repeatedly generated, triggering the callback a number
> of times. Eventually, Matlab complains that I have hit the recursion
> limit. But I haven't actually hit a -recursion- limit as the
> callback is not recursive: it's just being queued many times.

Maybe setting the slider's BusyAction property to 'cancel' results in a satisfactory user experience.

Hope this helps,
Matthias


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Walter Roberson  
View profile  
 More options Jan 15 2008, 2:38 pm
Newsgroups: comp.soft-sys.matlab
From: rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Date: Tue, 15 Jan 2008 19:38:24 +0000 (UTC)
Local: Tues, Jan 15 2008 2:38 pm
Subject: Re: callbacks / recursion limit
In article <20080115122414.f59220c7.matthias.fruehwi...@joanneum.at>,
Matthias Fruehwirth  <matthias.fruehwi...@joanneum.at> wrote:

>On Mon, 14 Jan 2008 23:01:55 +0000 (UTC)
>rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote:
>> I have a callback tied to a slider, and the callback takes a noticable
>> time to execute. If I hold down the mouse button on the slider arrow,
>> events are repeatedly generated, triggering the callback a number
>> of times. Eventually, Matlab complains that I have hit the recursion
>> limit. But I haven't actually hit a -recursion- limit as the
>> callback is not recursive: it's just being queued many times.
>Maybe setting the slider's BusyAction property to 'cancel' results in a satisfactory user experience.

Thanks, that was a good thought; unfortunately in practice it didn't
seem to make any difference for me.

What I have done now is put a persistant flag variable in the callback
routine; when it is set them I am already executing that callback
so I then just return before doing any work. Could be a problem if
I ever crash in that callback routine (because then it wouldn't be
cleared), but I'll worry about that some other time.
--
We regret to announce that sub-millibarn resolution bio-hyperdimensional
plasmatic space polyimaging has been delayed until the release
of Windows Vista SP2.


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Volkan  
View profile  
 More options Jan 15 2008, 6:04 pm
Newsgroups: comp.soft-sys.matlab
From: "Volkan " <vol...@buyukgungor.gmail.com>
Date: Tue, 15 Jan 2008 23:04:01 +0000 (UTC)
Local: Tues, Jan 15 2008 6:04 pm
Subject: Re: callbacks / recursion limit

> What I have done now is put a persistant flag variable in
the callback
> routine; when it is set them I am already executing that
callback
> so I then just return before doing any work.

Nice workaround. I played around a bit after reading your
post but couldn't come up with a working solution. So let me
tell you what does not work!

I tried clearing the callback in the beginning of the
function, and then restoring it before function terminates.
Tens of callbacks were queued anyway. Maybe Matlab takes a
copy of the callback property when mouse is clicked and
keeps using that. It's quite unexpected if you ask me.

However here is something that may be of use to you. In my
machine, if the callback function is involved in heavy
computations, additional callbacks are instantiated after
first function releases the CPU or something (purely
empirical observation here). So inserting the tiniest pause
before resetting your persistent flag may smooth things a
little further.

Sorry for writing all these observations with no foundation
what so ever. Hope they help anyway.

Volkan


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Garrity  
View profile  
 More options Jan 21 2008, 8:44 am
Newsgroups: comp.soft-sys.matlab
From: "Michael Garrity" <mNOSPAMgarr...@mathworks.com>
Date: Mon, 21 Jan 2008 08:44:11 -0500
Local: Mon, Jan 21 2008 8:44 am
Subject: Re: callbacks / recursion limit

 The most common cause of this is that your callback is
doing something that lets more events  get processed and
these events trigger another copy of the callback. When
this happens, you get multiple copies of the callback piled
up on the stack until you hit the recursion limit.

 The most common thing that callbacks do that cause
events to be processed is to call "drawnow". You need
to do this if you want to get a figure window to repaint,
but it lets all events through, including more mouse events.

 The simplest workaround for this is to pass the "expose"
argument to the drawnow function. This will tell it to process
the events that are needed to redraw the figure window, but
leave all of the other events queued up until the callback is
done.

 Unfortunately, it is possible that the events are getting processed
as a side effect of something other than the drawnow command.
In that case there isn't really a simple fix.

    -MPG-


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Riccardo  
View profile  
 More options Jan 21 2008, 11:10 am
Newsgroups: comp.soft-sys.matlab
From: "Riccardo " <no...@nospam.org>
Date: Mon, 21 Jan 2008 16:10:04 +0000 (UTC)
Local: Mon, Jan 21 2008 11:10 am
Subject: Re: callbacks / recursion limit
rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fmj23g$a5...@canopus.cc.umanitoba.ca>...
> In article

<20080115122414.f59220c7.matthias.fruehwi...@joanneum.at>,

to 'cancel' results in a satisfactory user experience.

Have you tried checking the m-function stack (see dbstack)
and return in case the function is already listed ?
If it works, it should prevent stack pile-ups, without the
problems associated to additional persistent flags.

    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google