User Tools

Site Tools


lambda_scheme

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
lambda_scheme [2013/09/22 01:52]
troyane [If you need to access UI]
lambda_scheme [2013/09/22 02:22]
troyane [Todays approach to database access in Mixxx]
Line 13: Line 13:
   - Populate table models from query results (if it's necessary)   - Populate table models from query results (if it's necessary)
  
-The main problem of such scheme is conducting the db access mostly from the Main thread. That's why while query'​s pending we face UI locking.+The main problem of such scheme is conducting the db access mostly from the Main thread. That's why while query'​s pending we face UI freezing.
  
 The main requirement is avoid hanging of UI (or minimize hanging up to 16 ms given by the display refresh rate, but not more). The main requirement is avoid hanging of UI (or minimize hanging up to 16 ms given by the display refresh rate, but not more).
Line 74: Line 74:
 //This can be uses safely during construction time of Mixxx but should be avoided in run time.// //This can be uses safely during construction time of Mixxx but should be avoided in run time.//
  
-If you can't move on until code in lambda executes. For example, when you need results of some query in initialization of your class. ​So you may use some kind of "​callSync"​ -- do it with locks. The algorithm is quite easy: +If you can't move on until code in lambda executes. For example, when you need results of some query in initialization of your class. ​Do it with ''​callSync''​. ​
-  - In your context create (even in stack) ''​QMutex mutex''​ +
-  - Do ''​mutex.lock()''​ +
-  - Do as usual you do with ''​callAsync()'',​ but with little correction in lambda: add ''&​mutex''​ to lambdas catchlist; add ''​mutex.unlock()''​ at the end of your lambda code (it must be surrounded by lambda) +
-  - After ''​callSync'' ​code do ''​mutex.lock()''​ and imidiately ''​mutex.unlock()''​+
  
-Completing this instruction,​ we do as it was previously, but with pause of further execution until respective lambda will be executed and respective mutex will be unlocked. Beware your lambda must wait whole queue.  +Completing this instruction,​ we do as it was previously, but with pause of further execution until respective lambda will be executed and respective mutex will be unlocked. Beware your lambda must wait whole lambda ​queue. ​
- +
-Other way to implement such behaviour is to emit signals like for accessing UI.+
  
 ==== Lambdas queue upper bound ==== ==== Lambdas queue upper bound ====
lambda_scheme.txt · Last modified: 2013/09/22 05:21 by troyane