From 482878aa8029b3613824c1e68705abb0657033a3 Mon Sep 17 00:00:00 2001 From: Mason Protter Date: Tue, 30 Jan 2024 15:28:53 +0100 Subject: [PATCH] Add taskid function, update readme (#13) * add taskid function, update readme * bump version --- Project.toml | 2 +- README.md | 18 ++++++++++++------ readme_generator.jl | 16 +++++++++++----- src/tools.jl | 7 +++++++ 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Project.toml b/Project.toml index d410b969..d19d0d1e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "OhMyThreads" uuid = "67456a42-1dca-4109-a031-0a68de7e3ad5" authors = ["Mason Protter "] -version = "0.2.0" +version = "0.2.1" [deps] BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66" diff --git a/README.md b/README.md index b679ca6e..b888aa8d 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,18 @@ #### This package is in very early development and is not yet registered -This is meant to be a simple, unambitious package that provides basic, user-friendly ways of doing -multithreaded calculations via higher-order functions, with a focus on [data parallelism](https://en.wikipedia.org/wiki/Data_parallelism). - -Unlike most JuliaFolds2 packages, it is not built off of [Transducers.jl](https://github.com/JuliaFolds2/Transducers.jl), nor is it a building block of Transducers.jl, instead OhMyThreads is meant to be a simpler, more maintainable, and more accessible alternative to packages like [ThreadsX.jl](https://github.com/tkf/ThreadsX.jl) or [Folds.jl](https://github.com/JuliaFolds2/Folds.jl). - -OhMyThreads.jl re-exports the very useful function `chunks` from [ChunkSplitters.jl](https://github.com/JuliaFolds2/ChunkSplitters.jl), and provides the following functions: +This is meant to be a simple, unambitious package that provides user-friendly ways of doing task-parallel +multithreaded calculations via higher-order functions, with a focus on +[data parallelism](https://en.wikipedia.org/wiki/Data_parallelism) without needing to expose julia's +[Task](https://docs.julialang.org/en/v1/base/parallel/) model to users. + +Unlike most JuliaFolds2 packages, it is not built off of +[Transducers.jl](https://github.com/JuliaFolds2/Transducers.jl), nor is it a building block for Transducers.jl. +Rather, OhMyThreads is meant to be a simpler, more maintainable, and more accessible alternative to packages +like [ThreadsX.jl](https://github.com/tkf/ThreadsX.jl) or [Folds.jl](https://github.com/JuliaFolds2/Folds.jl). + +OhMyThreads.jl re-exports the very useful function `chunks` from +[ChunkSplitters.jl](https://github.com/JuliaFolds2/ChunkSplitters.jl), and provides the following functions:
tmapreduce

diff --git a/readme_generator.jl b/readme_generator.jl index 65b8abd9..72f1283f 100644 --- a/readme_generator.jl +++ b/readme_generator.jl @@ -1,17 +1,23 @@ using OhMyThreads -open("README.md", "w+") do io +open(joinpath(@__DIR__(), "README.md"), "w+") do io println(io, """ # OhMyThreads #### This package is in very early development and is not yet registered -This is meant to be a simple, unambitious package that provides basic, user-friendly ways of doing -multithreaded calculations via higher-order functions, with a focus on [data parallelism](https://en.wikipedia.org/wiki/Data_parallelism). +This is meant to be a simple, unambitious package that provides user-friendly ways of doing task-parallel +multithreaded calculations via higher-order functions, with a focus on +[data parallelism](https://en.wikipedia.org/wiki/Data_parallelism) without needing to expose julia's +[Task](https://docs.julialang.org/en/v1/base/parallel/) model to users. -Unlike most JuliaFolds2 packages, it is not built off of [Transducers.jl](https://github.com/JuliaFolds2/Transducers.jl), nor is it a building block of Transducers.jl, instead OhMyThreads is meant to be a simpler, more maintainable, and more accessible alternative to packages like [ThreadsX.jl](https://github.com/tkf/ThreadsX.jl) or [Folds.jl](https://github.com/JuliaFolds2/Folds.jl). +Unlike most JuliaFolds2 packages, it is not built off of +[Transducers.jl](https://github.com/JuliaFolds2/Transducers.jl), nor is it a building block for Transducers.jl. +Rather, OhMyThreads is meant to be a simpler, more maintainable, and more accessible alternative to packages +like [ThreadsX.jl](https://github.com/tkf/ThreadsX.jl) or [Folds.jl](https://github.com/JuliaFolds2/Folds.jl). -OhMyThreads.jl re-exports the very useful function `chunks` from [ChunkSplitters.jl](https://github.com/JuliaFolds2/ChunkSplitters.jl), and provides the following functions: +OhMyThreads.jl re-exports the function `chunks` from +[ChunkSplitters.jl](https://github.com/JuliaFolds2/ChunkSplitters.jl), and provides the following functions: """) for sym ∈ (:tmapreduce, :treducemap, :treduce, :tmap, :tmap!, :tforeach, :tcollect) println(io, "

$sym \n

\n") diff --git a/src/tools.jl b/src/tools.jl index 5c386704..93591e1d 100644 --- a/src/tools.jl +++ b/src/tools.jl @@ -15,4 +15,11 @@ Returns the thread id of the `n`th Julia thread in the `:default` threadpool. end end +""" + taskid() :: UInt + +Return a `UInt` identifier for the current running [Task](https://docs.julialang.org/en/v1/base/parallel/#Core.Task). This identifier will +""" +taskid() = objectid(current_task()) + end # Tools