- Table of Contents
- Why does this even exist?
- Features
- Installation
- Usage
- API
- Found a Bug?
- Contribution
- LICENSE
- References
It just spawned in my head. It is made to control how frequent a task gets called. But i think valve is a great library for tasks like http requests or datastore requests that has to have a rate.
- Precise Rate Limiting: Enforces a configurable execution frequency (Hz) by injecting calculated delays between tasks, preventing burst processing from overwhelming downstream systems.
- Bounded FIFO Buffering: Utilizes a First-In-First-Out queue with a strict capacity limit, automatically rejecting excess insertions to ensure predictable memory usage.
- Non-Blocking Concurrency: Offloads task processing to a dedicated thread (task.defer), allowing the main application loop to continue uninterrupted while the queue drains.
- Thread Synchronization: Includes await capabilities, allowing external threads to yield *and automatically resume only after the valve has finished processing its workload.
- Result Persistence: Optionally aggregates the return values of all successful callbacks into an outcomes table for retrieval after execution.
To install this to your computer you have this options;
- Clone this repository by running following command
git clone https://github.com/Cod2rDude/queues
- Get the latest release of .rbxm file from releases
- Or add this as a submodule to your project
git submodule add https://github.com/Cod2rDude/queues [PATH]
Wally will be added in future.
local lib = require(path.to.module)
-- Create a new valve with rate of 20 and queue size of 5
local myValve = lib.new(20, 5, false, false)
-- rate, queueSize, stopOnError, saveOutcomes
for i = 1, 5 do
myValve:enqueue(function()
print(string.format("This is %d'th callback", i))
end, false)
-- callback, runImmediate
end
myValve:run() -- This is 1'th callback
-- This is 2'th callback
-- This is 3'th callback
-- This is 4'th callback
-- This is 5'th callback local lib = require(path.to.module)
-- Create a new valve with rate of 20 and queue size of 5
local myValve = lib.new(20, 5, false, false)
for i = 1, 5 do
myValve:enqueue(function()
print(string.format("This is %d'th callback", i))
end, false)
end
myValve:run() -- This is 1'th callback
-- This is 2'th callback
-- This is 3'th callback
-- This is 4'th callback
-- This is 5'th callback
myValve:await()
print("Done") -- Will print when valve finishes.Please check out source code for further info about api.
If you encounter any issues or unexpected behavior, please let me know! Your feedback helps make this library more stable.
- Check the existing issues to see if it has already been reported.
- If not, open a new issue and describe the problem.
- Provide a small code snippet to reproduce the bug if possible.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
To maintain the stability of the library, direct commits to the main branch are restricted. Please follow the workflow below to suggest changes:
- Fork the Project: Create your own copy of this repository.
- Create a Feature Branch:
git checkout -b feature/AmazingFeature
- Commit your changes:
git commit -m 'Add some AmazingFeature' - Push to branch:
git push origin feature/AmazingFeature
- Open a Pull Request: Navigate to the original repository and click "New Pull Request". Describe your changes in detail so they can be reviewed.
Once your Pull Request is merged, GitHub will automatically list you in the official "Contributors" section of the repository. (i guess so)
After a successful merge, I will also manually add your name and contribution to the table below!
We appreciate contributions you will make but we will also highly appreciate you to follow our guidelines while contributing.
- Of course make sure your code is efficient.
- No nsfw links, swearing or anything like those.
- Maybe follow the coding style we do.
- That's it!
This project is licensed under The MIT License