mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-01 10:48:52 +00:00
Update README.md (#4)
This commit is contained in:
@@ -1,35 +1,26 @@
|
||||
# fxserver-async
|
||||
# async
|
||||
Async utilities for FXServer
|
||||
|
||||
[INSTALLATION]
|
||||
|
||||
## Installation
|
||||
Set it as a dependency in you __resource.lua
|
||||
|
||||
```
|
||||
server_script '@async/async.lua'
|
||||
```
|
||||
|
||||
[USAGE]
|
||||
|
||||
## Usage
|
||||
```
|
||||
local tasks = {}
|
||||
|
||||
for i=1, 100, 1 do
|
||||
|
||||
for i = 1, 100, 1 do
|
||||
local task = function(cb)
|
||||
|
||||
SetTimeout(1000, function()
|
||||
|
||||
local result = math.random(1, 50000)
|
||||
|
||||
cb(result)
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
table.insert(tasks, task)
|
||||
|
||||
end
|
||||
|
||||
Async.parallel(tasks, function(results)
|
||||
@@ -43,5 +34,4 @@ end)
|
||||
Async.series(tasks, function(results)
|
||||
print(json.encode(results))
|
||||
end)
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user