The Volatile class
Volatile
&reftitle.intro;
The Volatile class is new to pthreads v3. Its
introduction is a consequence of the new immutability semantics of
Threaded members of Threaded
classes. The Volatile class enables for mutability
of its Threaded members, and is also used to store
PHP arrays in Threaded contexts.
&reftitle.classsynopsis;
Volatile
Volatile
extends
Threaded
Collectable
Traversable
&InheritedMethods;
&reftitle.examples;
New immutability semantics of Threaded
data = new Threaded();
// attempt to overwrite a Threaded property of a Threaded class (invalid)
$this->data = new stdClass();
}
}
var_dump((new Task())->data);
]]>
&example.outputs.similar;
Volatile use-case
data = new Threaded();
// attempt to overwrite a Threaded property of a Volatile class (valid)
$this->data = new stdClass();
}
}
var_dump((new Task())->data);
]]>
&example.outputs.similar;