Re: _sleep and _wakeup



Water Cooler v2 wrote:
I didn't understand from this

http://in2.php.net/manual/en/language.oop.magic-functions.php

whether we, the programmer, have to implement _sleep and _wakeup (like
.NET's IDisposable.Dispose()) or it is done by PHP internally on a
class that uses resources?

Hi,

__sleep and __wakeup are the methods, that you can implement in your
class. They are just like events that occur before serialization and
after unserialization. Consider this:

class MyClass {
function __sleep() {
echo "__sleep\n";
return array();
}
function __wakeup() {
echo "__wakeup\n";
}
}

$c = new MyClass();
echo "Sleep: ";
$str = serialize($c);
echo "Wakeup: ";
$c1 = unserialize($str);

The output will be:
Sleep: __sleep
Wakeup: __wakeup

Sincerely,
Alexander
http://www.alexatnet.com/

.



Relevant Pages

  • Re: XScale sleep mode
    ... Setup sleep mode states for the output GPIO lines ... correctly the cpu state on wakeup. ... Get 7 registers at a time. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: [9fans] sleep/wakeup bug?
    ... you are using sleep and wakeup incorrectly, ... i was going to point you at devmnt but devmnt looks buggy to me. ... can wake the second sleep, intending to wake the first sleep. ...
    (comp.os.plan9)
  • Re: [9fans] sleep/wakeup bug?
    ... doing the whole thing inside an ilock) decrement the semaphore ... actually gone to sleep yet. ... sleep and one wakeup. ...
    (comp.os.plan9)
  • Re: [9fans] sleep/wakeup bug?
    ... sleep and one wakeup. ... that cpu2 runs all that before sleepstarts. ...
    (comp.os.plan9)
  • Re: USB suspend/remote wakeup on Vista vs. XP
    ... Ditto - I was also waking the system from sleep earlier with a mouse click, ... device won't wake from Sleep though, ... Still can't get the full wait-wake wakeup, however, which is my key problem ... I would think that the hub needn't independently ...
    (microsoft.public.development.device.drivers)