1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-11 16:49:51 +01:00
parallel/lib/Sync/Parcel.php

34 lines
1.1 KiB
PHP
Raw Normal View History

2016-12-30 02:16:04 +01:00
<?php
2016-08-18 18:04:48 +02:00
2016-08-23 23:47:40 +02:00
namespace Amp\Parallel\Sync;
/**
2015-12-05 06:50:32 +01:00
* A parcel object for sharing data across execution contexts.
*
2015-12-05 06:50:32 +01:00
* A parcel is an object that stores a value in a safe way that can be shared
* between different threads or processes. Different handles to the same parcel
* will access the same data, and a parcel handle itself is serializable and
* can be transported to other execution contexts.
*
2015-12-05 06:50:32 +01:00
* Wrapping and unwrapping values in the parcel are not atomic. To prevent race
* conditions and guarantee safety, you should use the provided synchronization
* methods to acquire a lock for exclusive access to the parcel first before
* accessing the contained value.
*/
2016-08-18 18:04:48 +02:00
interface Parcel extends Synchronizable {
/**
2015-12-05 06:50:32 +01:00
* Unwraps the parcel and returns the value inside the parcel.
*
2015-12-05 06:50:32 +01:00
* @return mixed The value inside the parcel.
*/
2015-12-05 06:50:32 +01:00
public function unwrap();
/**
2015-12-05 06:50:32 +01:00
* Clones the parcel object, resulting in a new, independent parcel.
*
2015-12-05 06:50:32 +01:00
* When a parcel is cloned, a new parcel is created and the original
* parcel's value is duplicated and copied to the new parcel.
*/
2015-12-05 06:50:32 +01:00
public function __clone();
}