https://github.com/invenia/deferredfutures.jl
Julia Futures which are initialized when written to
https://github.com/invenia/deferredfutures.jl
async channels futures julia parallel
Last synced: 7 months ago
JSON representation
Julia Futures which are initialized when written to
- Host: GitHub
- URL: https://github.com/invenia/deferredfutures.jl
- Owner: invenia
- License: other
- Created: 2016-07-01T01:19:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-08-16T19:34:23.000Z (over 4 years ago)
- Last Synced: 2025-04-05T00:23:12.274Z (11 months ago)
- Topics: async, channels, futures, julia, parallel
- Language: Julia
- Size: 50.8 KB
- Stars: 5
- Watchers: 4
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# DeferredFutures
[](https://travis-ci.org/invenia/DeferredFutures.jl)
[](https://ci.appveyor.com/project/iamed2/deferredfutures-jl/branch/master)
[](https://codecov.io/gh/invenia/DeferredFutures.jl)
A `DeferredFuture` is like a regular Julia `Future`, but is initialized when `put!` is called on it.
This means that the data in the `DeferredFuture` lives with the process the data was created on.
The process the `DeferredFuture` itself lives on never needs to fetch the data to its process.
This is useful when there is a lightweight controller process which handles scheduling work on and transferring data between multiple machines.
## Usage
Use a `DeferredFuture` as you would a `Future`.
```julia
julia> DeferredFuture()
DeferredFuture at (1,1,1)
julia> DeferredFuture(3)
DeferredFuture at (3,1,2)
```
You can also use a `DeferredChannel` as you would a `RemoteChannel`.
```julia
julia> DeferredChannel(()->Channel{Int}(10), 4)
DeferredChannel(#1) at (4,1,3)
julia> DeferredChannel(4)
DeferredChannel(DeferredFutures.#2) at (4,1,4)
julia> DeferredChannel(4, 128; content=Int)
DeferredChannel(DeferredFutures.#2) at (4,1,5)
```
Note that `DeferredChannel()` will create a `RemoteChannel` with `RemoteChannel(()->Channel{Any}(1), myid())` by default.
Furthermore, `@defer` can be used when creating a `Future` or `RemoteChannel` to create their deferred counterparts.
```julia
julia> @defer Future()
DeferredFuture at (1,1,6)
julia> @defer RemoteChannel(()->Channel{Int}(10))
DeferredChannel(#3) at (1,1,7)
```
Note that `DeferredFuture(n)` does not control where the data lives, only where the `RemoteChannel` which refers to the data lives.
## License
DeferredFutures.jl is provided under the [MIT "Expat" License](LICENSE.md).