On Tue, Aug 19, 2014 at 1:29 PM, Marcos Caceres <w...@marcosc.com> wrote: > On August 19, 2014 at 2:08:04 PM, Jonas Sicking (jo...@sicking.cc) wrote: >> > > How would you handle feature detection with this design? >> >> This is a good question. I don't have a better solution than adding >> separate DisplayWakeLock() and SystemWakeLock() classes. >> > > Might make sense to do it this way regardless. It might be that we need to > add different behavior for each type of lock in the future. > > Ok, so taking into consideration the feedback received so far - how about > something like: > > ``` > [Constructor] > interface DisplayLock : WakeLock { > static readonly attribute boolean isHeld; > } > > [Constructor] > interface SystemLock : WakeLock { > static readonly attribute boolean isHeld; > }
Why is isHeld still used here? You don't need it to avoid squashing someone else's lock with this design, and several people have pointed out that exposing it is a footgun, as people might check it and decide they don't need to request their own lock (only to be screwed when the other lock releases earlier or later than they expected). ~TJ