Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uberi/parallelist
A simple parallelism library for AutoHotkey.
https://github.com/uberi/parallelist
Last synced: 12 days ago
JSON representation
A simple parallelism library for AutoHotkey.
- Host: GitHub
- URL: https://github.com/uberi/parallelist
- Owner: Uberi
- License: agpl-3.0
- Created: 2011-08-26T19:11:43.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2012-12-17T21:22:45.000Z (almost 12 years ago)
- Last Synced: 2024-10-10T22:28:20.766Z (about 1 month ago)
- Language: AutoHotkey
- Homepage:
- Size: 140 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Parallelist
===========
A simple parallelism library for the AutoHotkey programming language.Progress
--------This project is currently in progress and is suitable for testing and development purposes only.
Goal
----Parallel and multithreaded programs are uncommon to see in AutoHotkey, and when they do appear, the infrastructure is often ad hoc and single use.
Parallelist is an attempt to create a simpler way to parallelize problems. A script sets up a job, and after starting some workers a queue can be populated with data. Parallelist will manage event handling, worker assignment, and results collection by itself, automatically and behind the scenes. The script can be informed of when the job is done, and easily collect the results.
Parallelist aims to allow more AutoHotkey applications to take advantage of the extra processing power available to many computers today in the form of multiple processors. Already parallel applications will benefit from a decrease in the complexity of the parallel code, while others can easily be augmented to make best use of modern hardware.
Design
------Parallelist is based on the following workflow:
1. Script creates a job, containing the logic to be used by each worker.
2. Script starts up the number of workers desired.
3. Script starts the job and starts adding data to the queue.
4. Parallelist dispatches tasks to individual workers, which do their processing independently.
5. Workers send their results back to Parallelist, and receive more tasks if there are any left.
6. Parallelist collects the data, cleans it up, and presents the results back to the script.The Parallelist workflow is designed to abstract the complexity of parallelism away from your code, so you can focus more on what the application _does_.
Usage Example
-------------A simple script that counts the number of lines in all the ".txt" files in a given library, in parallel.
#Include
LineCounter = ;set up a line counter program
(
class Worker
{
Process(Task)
{
FileName := Parallelist.Data ;retrieve the file name
LineCount := 0
Loop, Read, %FileName% ;loop through each line of the file
{
If A_LoopReadLine Is Not Space ;if the line is not blank or purely whitespace
LineCount ++ ;increment the line count
}
Parallelist.Output := LineCount ;set the output to the file's line count
Return, 0
}
}
)
Job := new Parallelist(LineCounter) ;open a line counter job
Loop, 3
Job.AddWorker() ;add a worker to the job
Job.RemoveWorker() ;remove a worker from the job
Job.Start() ;start execution of the job
Loop, %A_ScriptDir%\Data\*.txt ;loop through each ".txt" file in the "Data" subfolder of the script directory
Job.Queue.Insert(A_LoopFileLongPath) ;append a task to the queue
While, Job.Working ;wait for the workers to finish the tasks placed on the queue
Sleep, 1
Job.Stop() ;stop the workers after they have completed the task they are currently working on
TotalLines := 0
FileCount := Job.Result.MaxIndex() ;get the number of files processed
For Index, Value In Job.Result ;loop through each result
TotalLines += Value ;add up the number of lines
MsgBox, Found %TotalLines% non-blank lines in %FileCount% files.