#Non-interruptible thread sleeping

17 messages · Page 1 of 1 (latest)

abstract barn
#

Is is possible to sleep a thread in such a way that's not affected by the thread being interrupted? I know when a thread is waiting to acquire a lock it's not bothered by interruptions so is there such a thing without having to sit on some objects monitor?

lapis basinBOT
#

This post has been reserved for your question.

Hey @abstract barn! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

wanton mantle
#

I guess you can check whether you slept long enough and if not, sleep what's left

#

Couldn't you simply opt out of interrupting?

abstract barn
#

I could opt out of interrupting but that would complicate things a lot

#

and the point isn't to sleep for some particular time period

#

the point is to sleep for any time at all because otherwise my cpu usage goes to 50%

wanton mantle
#

Who smells X Y problem?

abstract barn
#

That could very well be the case but I would rather hold off on rewriting a bunch of stuff until after I find out whether it's at all possible

#

although it sounds like it probably isn't

unique anvil
#

Please be more specific

#

What exactly are you trying to achieve?

abstract barn
#

Well I am making something like a video player and you know these cool sliders the video players have where you drag them and go around the video?

#

well I need that skipping around the video to be as interactive as possible so I need to process the most recent slider move but when the slider handle is just taken and dragged across that equals a bunch of these skip requests and the way I deal with this is sleep the thread that handles the skipping for a bit at the beginning of the method and if another skip request comes I interrupt that sleeping and start processing the new one

#

the problem is when the slider is getting dragged across the interrupt requests come to fast and the thread is basically active 100% of the time