package/synchronized/lib/synchronized library

This simulates the synchronized feature of Java in an async way

Create a shared Lock object and use it using the Lock.synchronized method to prevent concurrent access to a shared resource.

class MyClass {
 final _lock = new Lock();
 Future<void> myMethod() async {
   await _lock.synchronized(() async {
     step1();
     step2();
     step3();
   });
 }

Classes

Lock
Object providing the implicit lock.
MultiLock
A multi lock that locks multiple locks at the same time.

Extensions

TekartikLockExtension on Lock
Extension on Lock to provide synchronous execution when possible