- Kotlin Standard Library Cookbook
- Samuel Urbanowicz
- 119字
- 2021-07-23 19:05:57
Inlining parameters of closure type
Usage of higher-order functions can lead to a decrease of runtime performance. Memory allocations of the functions passed as lambda arguments and their virtual calls in a function body lead to runtime overhead. However, in many cases, we can eliminate this type of overhead by inlining the lambda expression parameters.
In this recipe, we are going to implement the lock() function that will automate work with the Java java.util.concurrent.locks.Lock interface. The function will take two arguments—an instance of the Lock interface and the function that should be invoked after the lock is acquired. Finally, our lock() function should release the lock. We also want to allow making the function parameter inlined.
推薦閱讀
- Android Jetpack開發:原理解析與應用實戰
- 編程的修煉
- Oracle從新手到高手
- 信息可視化的藝術:信息可視化在英國
- Django開發從入門到實踐
- Android 應用案例開發大全(第3版)
- Learning Apache Mahout Classification
- Learning SciPy for Numerical and Scientific Computing(Second Edition)
- Mastering Data Mining with Python:Find patterns hidden in your data
- Mastering Web Application Development with AngularJS
- Cocos2d-x Game Development Blueprints
- Robot Framework Test Automation
- PHP Microservices
- 優化驅動的設計方法
- Jakarta EE Cookbook