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
Next revision Both sides next revision
lambda_scheme [2013/09/22 01:51]
troyane [Scheme in few words]
lambda_scheme [2013/09/22 02:01]
troyane [Not Asynchronous, but synchronous]
Line 68: Line 68:
  
 ===== Some moments of lambda usage ===== ===== Some moments of lambda usage =====
-==== If you need to access UI ====+==== If you need to access UI from lambda ​====
 See [[lambda_rules|Rules and arrangements using lambdas scheme for database access]] See [[lambda_rules|Rules and arrangements using lambdas scheme for database access]]
  
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