Quantcast
Download
(5 Kb)
Download
Updated: 07/31/20 01:48 PM
Pictures
File Info
Compatibility:
Stonethorn (6.1.0)
Greymoor (6.0.5)
Updated:07/31/20 01:48 PM
Created:09/02/18 10:37 AM
Monthly downloads:97,454
Total downloads:444,889
Favorites:383
MD5:
6.0.5
LibAsync  Popular! (More than 5000 hits)
Version: 2.2.0
by: votan [More]
Description
Read this article of the Wiki.

API
local async = LibAsync
local task = async:Create(name)

The signature of FuncOfTask is:
Code:
local function(task)
end
-- Get the current context, if you are within a FuncOfTask or nil.
Code:
function async:GetCurrent()
-- Create an interruptible task context.
Code:
function async:Create(name)
-- Resume the execution context.
Code:
task:Resume()
-- Suspend the execution context and allow to resume anytime later.
Code:
function task:Suspend()
-- Interupt and fully stop the execution context. Can be called from outside to stop everything.
Code:
function task:Cancel()
-- Run the given FuncOfTask in your task context execution.
Code:
function task:Call(funcOfTask)
-- Continue your task context execution with the given FuncOfTask after the previous as finished.
Code:
function task:Then(funcOfTask)
-- Start an interruptible for-loop.
Code:
function task:For(from, to, step)
function task:For(pairs(tbl))
function task:For(ipairs(tbl))
-- Execute the async-for with the given step-function. The parameters of the step-function are those you would use in your for body.
Code:
function task:Do(func)
The signature if func is function(index) or function(key, value)
If you return async.BREAK within func, it will break the loop.

-- Suspend the execution of your task context for the given delay in milliseconds and then call the given FuncOfTask to continue.
Code:
function task:Delay(delay, funcOfTask)
-- Stop the delay created by Delay
Code:
function task:StopTimer()
-- Set a FuncOfTask as a final handler. Called even if something went wrong in your context.
Code:
function task:Finally(funcOfTask)
-- Set a FuncOfTask as an error handler. Called if something went wrong in your context.
Code:
function task:OnError(funcOfTask)

Example 1
Lua Code:
  1. local async = LibAsync
  2.  
  3. local task = async:Create("example1")
  4.  
  5. local i=1
  6. local function Hello() d("Hello") end
  7. local function World() d("World") end
  8.  
  9. task:Call(function(task)
  10.  d(i)
  11.  task:Call(Hello):Then(World)
  12.  i = i + 1
  13.  return i<1000
  14. end):Then(function() d("end") end)
Example 2
Lua Code:
  1. local async = LibAsync
  2.  
  3. local task = async:Create("example2")
  4.  
  5. local start = GetGameTimeMilliseconds()
  6.  
  7. task:For (1,1000):Do(function(index) d(index) end):Then(
  8. function()
  9.   task:For (pairs({"a", "b"})):Do(function(key, value) d(key,value)
  10.     task:For (ipairs({"c", "d"})):Do(function(key, value) d(key,value)  end)
  11.  end)
  12. end):For(1001,1010):Do(function(index) d(index) end):Then(function(task)
  13.   df("%ims", GetGameTimeMilliseconds() - start)
  14. end)
Remarks
  • Yes, using LibAsync increases the total duration of the process for a better framerate.
  • Lua code can cause hiccups and (micro-)freezes, but has nothing to do the lag.
  • Lua can cause crash to bug report, if too much memory is allocated within one frame. (e.g. string operations) => Spread you code over time.
  • Lua can cause kick to login, if too much server request are done within a time range. (e.g. map pings/buy/sell/ignore, etc.) => Spread you code over time.
version 2.2.0:
- Update to API 100032 "Stonethorn".
- New async functions: While and WaitUntil.

version 2.1.0: Register scheduler as late as possible to take count to all actions not using LibAsync.

version 2.0.2:
- Update to API 100029 "Dragonhold".

version 2.0.1:
- Update to API 100028 "Scalebreaker".

version 2.0.0:
- API bump 100027 "Elsweyr".
- Need to go to 2.0 because of the version check of LibStub.

version 1.10.0:
- API bump 100027 "Elsweyr".
- Use of LibStub is optional.

version 1.9.0:
- Update to API 100026 "Wrathstone".
- For V-Sync off/G-Sync the minimum target framerate is 80.

version 1.8.1:
- Work without LibStub as well.

version 1.8.0:
- API update "Murkmire".
- Adjustment to scheduler calculation: Reduce allowed-time after a burst even if loops still running.
- Change from GetGameTimeMilliseconds to GetGameTimeSeconds, which has in fact more precision. Thanks to @zsban.
Optional Files (0)


Archived Files (9)
File Name
Version
Size
Uploader
Date
2.1.0
5kB
votan
12/13/19 02:49 PM
2.0.2
5kB
votan
10/03/19 04:39 AM
2.0.1
5kB
votan
07/29/19 02:17 PM
2.0.0
5kB
votan
05/15/19 01:16 PM
1.10.0
5kB
votan
05/04/19 01:36 PM
1.9.0
4kB
votan
02/23/19 10:15 AM
1.8.1
4kB
votan
11/09/18 01:07 PM
1.8.0
6kB
votan
10/06/18 02:10 PM
1.7
6kB
votan
09/02/18 10:37 AM


Post A Reply Comment Options
Unread 10/26/18, 10:04 AM  
Kestrelator

Forum posts: 0
File comments: 28
Uploads: 0
Error at crafting station, when deconstructing:

Code:
user:/AddOns/LibAsync/LibAsync.lua:35: user:/AddOns/RulebasedInventory/Modules/ActionExecution.lua:286: operator + is not supported for nil + number
stack traceback:
user:/AddOns/RulebasedInventory/Modules/ActionExecution.lua:286: in function 'ExecuteAction'
|caaaaaa<Locals> status = true, priority = 1, bagId = 6, slotIndex = 5, stackCountChange = -1, executionCounter = 0, cacheId = 2, rowIndex = 5, bagCache = tbl, itemInstanceIdLookup = tbl, row = tbl, lookup = tbl, delay = 0, rowUpdate = tbl </Locals>|r
(tail call): ?
[C]: in function 'pcall'
user:/AddOns/LibAsync/LibAsync.lua:21: in function 'DoCallback'
|caaaaaa<Locals> job = tbl, callstackIndex = 1 </Locals>|r
user:/AddOns/LibAsync/LibAsync.lua:49: in function 'DoJob'
|caaaaaa<Locals> job = tbl, index = 1 </Locals>|r
user:/AddOns/LibAsync/LibAsync.lua:100: in function 'async.Scheduler'
|caaaaaa<Locals> start = 2220.4016113281, runTime = 2220.4111899, cpuLoad = 0.0094038718748379 </Locals>|r
(tail call): ?
stack traceback:
[C]: in function 'error'
user:/AddOns/LibAsync/LibAsync.lua:35: in function 'DoCallback'
|caaaaaa<Locals> job = tbl, callstackIndex = 1, success = false, shouldContinue = "user:/AddOns/RulebasedInven..." </Locals>|r
user:/AddOns/LibAsync/LibAsync.lua:49: in function 'DoJob'
|caaaaaa<Locals> job = tbl, index = 1 </Locals>|r
user:/AddOns/LibAsync/LibAsync.lua:100: in function 'async.Scheduler'
|caaaaaa<Locals> start = 2220.4016113281, runTime = 2220.4111899, cpuLoad = 0.0094038718748379 </Locals>|r
(tail call): ?
Report comment to moderator  
Reply With Quote
Unread 10/26/18, 11:22 AM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 514
File comments: 1349
Uploads: 35
Re: Error at crafting station, when deconstructing:

Originally Posted by Kestrelator
Code:
user:/AddOns/LibAsync/LibAsync.lua:35: user:/AddOns/RulebasedInventory/Modules/ActionExecution.lua:286: operator + is not supported for nil + number
stack traceback:
user:/AddOns/RulebasedInventory/Modules/ActionExecution.lua:286: in function 'ExecuteAction'
|caaaaaa<Locals> status = true, priority = 1, bagId = 6, slotIndex = 5, stackCountChange = -1, executionCounter = 0, cacheId = 2, rowIndex = 5, bagCache = tbl, itemInstanceIdLookup = tbl, row = tbl, lookup = tbl, delay = 0, rowUpdate = tbl </Locals>|r
(tail call): ?
[C]: in function 'pcall'
user:/AddOns/LibAsync/LibAsync.lua:21: in function 'DoCallback'
|caaaaaa<Locals> job = tbl, callstackIndex = 1 </Locals>|r
user:/AddOns/LibAsync/LibAsync.lua:49: in function 'DoJob'
|caaaaaa<Locals> job = tbl, index = 1 </Locals>|r
user:/AddOns/LibAsync/LibAsync.lua:100: in function 'async.Scheduler'
|caaaaaa<Locals> start = 2220.4016113281, runTime = 2220.4111899, cpuLoad = 0.0094038718748379 </Locals>|r
(tail call): ?
stack traceback:
[C]: in function 'error'
user:/AddOns/LibAsync/LibAsync.lua:35: in function 'DoCallback'
|caaaaaa<Locals> job = tbl, callstackIndex = 1, success = false, shouldContinue = "user:/AddOns/RulebasedInven..." </Locals>|r
user:/AddOns/LibAsync/LibAsync.lua:49: in function 'DoJob'
|caaaaaa<Locals> job = tbl, index = 1 </Locals>|r
user:/AddOns/LibAsync/LibAsync.lua:100: in function 'async.Scheduler'
|caaaaaa<Locals> start = 2220.4016113281, runTime = 2220.4111899, cpuLoad = 0.0094038718748379 </Locals>|r
(tail call): ?
Hello Kestrelator,

the error occurs in RulebasedInventory. LibAsync is in this case just the library used.
__________________
@votan73 (EU - megaserver)
Report comment to moderator  
Reply With Quote
Unread 05/15/19, 12:43 AM  
akanderson

Forum posts: 1
File comments: 22
Uploads: 0
Unique map bug introduced

With the update that was done on 05-13-19, as part of the Potion Maker update, a bug was introduced with this library. The overlay for the zone a character is in that includes such things as wayshrines, mundus stones, dolmens, etc. shows the same regardless of the zone you choose either when pulling up the map directly or trying to travel using a wayshrine. The only way I've found to correct the bug is to replace the LibAsync subfolder that was included with the Potion Maker update with the separate one dated 02-23-19.
Report comment to moderator  
Reply With Quote
Unread 05/15/19, 12:57 AM  
Marazota

Forum posts: 196
File comments: 1277
Uploads: 0
Re: Unique map bug introduced

Originally Posted by akanderson
With the update that was done on 05-13-19, as part of the Potion Maker update, a bug was introduced with this library. The overlay for the zone a character is in that includes such things as wayshrines, mundus stones, dolmens, etc. shows the same regardless of the zone you choose either when pulling up the map directly or trying to travel using a wayshrine. The only way I've found to correct the bug is to replace the LibAsync subfolder that was included with the Potion Maker update with the separate one dated 02-23-19.
im using both and standalone library too

all fine
Report comment to moderator  
Reply With Quote
Unread 07/25/19, 03:53 AM  
merlight
AddOn Author - Click to view AddOns

Forum posts: 679
File comments: 213
Uploads: 12
@votan Hi, do you have this somewhere in repository (git/mercurial)? I wanted to use LibAsync:Sort, but the Quicksort implementation therein is so simplistic and slow that I ended up writing several different variants. Would like to propose one for inclusion.

In the end I didn't use any of the Quicksort variants, I think it's a bad algorithm for the task that LibAsync strives to accomplish. Now I'm using Heapsort, which has O(n logn) worst-case, and is very easy to split into consistently-sized work pieces.
Report comment to moderator  
Reply With Quote
Unread 06/23/20, 01:09 PM  
desertforce

Forum posts: 3
File comments: 95
Uploads: 0
Hi Votan...

With the latest update of the LibMapPins-1.0 library (r29 version) I received the following error. Since I am not sure if its related to your LibAsync or the LibMapPins, I wanted to let you know about it .

Code:
[C]: in function 'pcall'
user:/AddOns/LibAsync/LibAsync.lua:26: in function 'DoCallback'
<Locals> job = [table:3]{name = "VOTANS_MAP_CUSTOM_PIN_UPDATE", lastCallIndex = 1}, callstackIndex = 1 </Locals>
user:/AddOns/LibAsync/LibAsync.lua:56: in function 'DoJob'
<Local> job = [table:3], index = 1 </Locals>
user:/AddOns/LibAsync/LibAsync.lua:112: in function 'async.Scheduler'
<Locals> start = 131.04742431641, runTime = 131.0551048, name = "VOTANS_MAP_CUSTOM_PIN_UPDATE" </Locals>
.(string): name = VOTANS_MAP_CUSTOM_PIN_UPDATE
.(table): callstack = table: 000001C04128CAF8
.(number): lastCallIndex = 0 
.(function): onError = function: 000001C04128CB40
Best regards
De-chan
Report comment to moderator  
Reply With Quote
Unread 06/23/20, 01:33 PM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 514
File comments: 1349
Uploads: 35
Originally Posted by merlight
@votan Hi, do you have this somewhere in repository (git/mercurial)? I wanted to use LibAsync:Sort, but the Quicksort implementation therein is so simplistic and slow that I ended up writing several different variants. Would like to propose one for inclusion.

In the end I didn't use any of the Quicksort variants, I think it's a bad algorithm for the task that LibAsync strives to accomplish. Now I'm using Heapsort, which has O(n logn) worst-case, and is very easy to split into consistently-sized work pieces.
No, sorry. Not in github. But if you have a better quick-sort, I would intregate it.
__________________
@votan73 (EU - megaserver)
Report comment to moderator  
Reply With Quote
Unread 06/23/20, 01:37 PM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 514
File comments: 1349
Uploads: 35
Originally Posted by desertforce
Hi Votan...

With the latest update of the LibMapPins-1.0 library (r29 version) I received the following error. Since I am not sure if its related to your LibAsync or the LibMapPins, I wanted to let you know about it .

Code:
[C]: in function 'pcall'
user:/AddOns/LibAsync/LibAsync.lua:26: in function 'DoCallback'
<Locals> job = [table:3]{name = "VOTANS_MAP_CUSTOM_PIN_UPDATE", lastCallIndex = 1}, callstackIndex = 1 </Locals>
user:/AddOns/LibAsync/LibAsync.lua:56: in function 'DoJob'
<Local> job = [table:3], index = 1 </Locals>
user:/AddOns/LibAsync/LibAsync.lua:112: in function 'async.Scheduler'
<Locals> start = 131.04742431641, runTime = 131.0551048, name = "VOTANS_MAP_CUSTOM_PIN_UPDATE" </Locals>
.(string): name = VOTANS_MAP_CUSTOM_PIN_UPDATE
.(table): callstack = table: 000001C04128CAF8
.(number): lastCallIndex = 0 
.(function): onError = function: 000001C04128CB40
Best regards
De-chan
Hi De-chan, LibAsync is jut reporting an error. It is any custom pins update from map.
__________________
@votan73 (EU - megaserver)
Report comment to moderator  
Reply With Quote
Unread 06/23/20, 02:09 PM  
desertforce

Forum posts: 3
File comments: 95
Uploads: 0
Originally Posted by votan
Originally Posted by desertforce
Hi Votan...

With the latest update of the LibMapPins-1.0 library (r29 version) I received the following error. Since I am not sure if its related to your LibAsync or the LibMapPins, I wanted to let you know about it .

Code:
[C]: in function 'pcall'
user:/AddOns/LibAsync/LibAsync.lua:26: in function 'DoCallback'
<Locals> job = [table:3]{name = "VOTANS_MAP_CUSTOM_PIN_UPDATE", lastCallIndex = 1}, callstackIndex = 1 </Locals>
user:/AddOns/LibAsync/LibAsync.lua:56: in function 'DoJob'
<Local> job = [table:3], index = 1 </Locals>
user:/AddOns/LibAsync/LibAsync.lua:112: in function 'async.Scheduler'
<Locals> start = 131.04742431641, runTime = 131.0551048, name = "VOTANS_MAP_CUSTOM_PIN_UPDATE" </Locals>
.(string): name = VOTANS_MAP_CUSTOM_PIN_UPDATE
.(table): callstack = table: 000001C04128CAF8
.(number): lastCallIndex = 0 
.(function): onError = function: 000001C04128CB40
Best regards
De-chan
Hi De-chan, LibAsync is jut reporting an error. It is any custom pins update from map.
Hi...

So, its your Votans MiniMap addon thats putting out this error in combination with the latest LibMapPins-1.0 update. Ok, thank you for looking into it . For now I'll stay with the older r22 version of LibMapPins-1.0, since that is still working and I'll wait for you to make an update to the MapAddon...

Best regards
De-chan
Report comment to moderator  
Reply With Quote
Unread 07/24/20, 01:59 AM  
Eagleheart
 
Eagleheart's Avatar

Forum posts: 9
File comments: 3
Uploads: 0
Cool What older ver. to get so the error won't pop ?

I'm about to install Votans Minimap & good that came to look at comments before installing LibAsync. @Desertforce do you know what ver. to install so error won't pop & where to find it ? Wish Good weekend to author & fans.

Kindly: Fedaygin
__________________
​"Recycle, Reduce Single Plastic Use & Use Fabric Groceries Bag" Help friends & relatives: https://transferwise.com/invite/u/09205c True mid-market rate & transparent fees🤑Exceptional customer revs on Trustpilot. Good Telly Content must Continue. Check & Share Around Wicked Wide Web o/
https://docs.google.com/document/d/1...it?usp=sharing
Report comment to moderator  
Reply With Quote
Unread 07/24/20, 09:11 AM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 514
File comments: 1349
Uploads: 35
Re: What older ver. to get so the error won't pop ?

Originally Posted by Eagleheart
I'm about to install Votans Minimap & good that came to look at comments before installing LibAsync. @Desertforce do you know what ver. to install so error won't pop & where to find it ? Wish Good weekend to author & fans.

Kindly: Fedaygin
The LibMapPins has removed AUI support functions. That's why LibMapPins-1.0 r22 works for desertforce.
But that is not a problem of LibAsync.
You have to try out yourself. For me, all works as it should. (Developers always say that)

And Thank You.
__________________
@votan73 (EU - megaserver)
Report comment to moderator  
Reply With Quote
Unread 07/31/20, 05:08 PM  
DigitalHype

Forum posts: 1
File comments: 25
Uploads: 0
Inventory Insight errors after today's LibAsync update

[oops edit to add errors]

Just updated LibAsync and Inventory Insight is throwing errors now. Any thoughts?

user:/AddOns/IIfA/IIfA.lua:39: Cannot find a library instance of "LibAsync".
stack traceback:
user:/AddOns/LibStub/LibStub/LibStub.lua:87: in function 'LibStub:GetLibrary'
|caaaaaa<Locals> self = [table:1]{SILENT = T, minor = 7}, major = "LibAsync" </Locals>|r
user:/AddOns/IIfA/IIfA.lua:39: in function '(main chunk)'
|caaaaaa<Locals> BACKPACK = ud, BANK = ud, IIFA_COLOR_DEFAULT = [table:2]{a = 1, b = 1, g = 0.6, r = 0.2} </Locals>|r
Last edited by DigitalHype : 07/31/20 at 05:08 PM.
Report comment to moderator  
Reply With Quote
Unread 07/31/20, 05:12 PM  
DigitalHype

Forum posts: 1
File comments: 25
Uploads: 0
Re: Inventory Insight errors after today's LibAsync update

Appears I'm not the only one having issues with Inventory Insight after updating LibAsync to current.

Others are report that rolling back LibAsync to 2.1.0 solves the issue. See threads over in that addon:

https://www.esoui.com/downloads/info....html#comments
Report comment to moderator  
Reply With Quote
Unread 07/31/20, 08:09 PM  
fgoron2000

Forum posts: 0
File comments: 120
Uploads: 0
Re: Re: Inventory Insight errors after today's LibAsync update

Originally Posted by DigitalHype
Appears I'm not the only one having issues with Inventory Insight after updating LibAsync to current.

Others are report that rolling back LibAsync to 2.1.0 solves the issue. See threads over in that addon:

https://www.esoui.com/downloads/info....html#comments

This recommended fix worked fine for me, the caveat is simply that when Inventory Insight gets updated that you do a fresh install, but until that time, the fix worked
Report comment to moderator  
Reply With Quote
Unread 07/31/20, 11:20 PM  
DigitalHype

Forum posts: 1
File comments: 25
Uploads: 0
Re: Re: Re: Inventory Insight errors after today's LibAsync update

Originally Posted by fgoron2000
Originally Posted by DigitalHype
Appears I'm not the only one having issues with Inventory Insight after updating LibAsync to current.

Others are report that rolling back LibAsync to 2.1.0 solves the issue. See threads over in that addon:

https://www.esoui.com/downloads/info....html#comments

This recommended fix worked fine for me, the caveat is simply that when Inventory Insight gets updated that you do a fresh install, but until that time, the fix worked
Good to hear. But, this isn't a fix. This is a workaround. What needs to happen here? Does Inventory Insight need to so something to work with the new LibAsync? If so, what? I fear that InventoryInsight might be abandonware at this point. Do we need a fork, or is it still being maintained?
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: