https://github.com/arrufat/parallel-vala
Ease the use of parallel processing for Vala arrays
https://github.com/arrufat/parallel-vala
array parallel vala
Last synced: about 2 months ago
JSON representation
Ease the use of parallel processing for Vala arrays
- Host: GitHub
- URL: https://github.com/arrufat/parallel-vala
- Owner: arrufat
- License: gpl-3.0
- Created: 2017-06-03T19:30:46.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-15T09:16:36.000Z (almost 9 years ago)
- Last Synced: 2025-10-13T20:47:26.673Z (5 months ago)
- Topics: array, parallel, vala
- Language: Meson
- Size: 26.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Parallel Vala
Parallel Vala is a class that eases parallel processing for Vala arrays.
Here's an example about how to compute the first 30 Fibonacci numbers in parallel:
``` vala
using GLib;
using Parallel;
int main (string [] args) {
var array = new int[30];
var par = new ParArray ();
par.data = array;
par.num_threads = 4;
par.function = compute_fibonacci;
par.dispatch ();
for (var i = 0; i < array.length; i++) {
print ("Fibonacci (%d) = %u\n", i, array[i]);
}
return 0;
}
int fibonacci (int n) {
if (n < 2) {
return n;
} else {
return (fibonacci (n - 2) + fibonacci (n - 1));
}
}
void compute_fibonacci (ParArray p) {
p.data[p.index] = fibonacci (p.index);
}
```
To use it in your code, simply add these lines to your `meson.build`:
``` meson
parallel = subproject('parallel')
parallel_dep = parallel.get_variable('parallel_dep')
```
Then, add `parallel_dep` to your dependencies array.
Finally, copy the [`parallel-vala.wrap`][wrap] to your `subprojects` folder.
[wrap]:https://raw.githubusercontent.com/arrufat/parallel-vala/master/parallel-vala.wrap