stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.67k stars 1.56k forks source link

Very ineffective threading #937

Closed gentlee closed 3 years ago

gentlee commented 5 years ago

Your library is poorly written and definitely not lightweight because you create your own serial queue and perform all requests syncronously! Author of this lib doesn't understand multithreading and how things should be done.

You either leave synchronization for user so that he creates his own serial queue and decide if he want sync or async (and this is lightweight), or you create serial queue and make two versions for each function - sync and async.

Currently user will always block 2 threads, inner serial queue's thread and his own queue's thread that he uses not to block main one (or even main thread).

I would suggest to implement second approach not to break existing api.

jberkel commented 3 years ago

The point of the queue is not "effectiveness" but safety. And with SQLite most operations are so fast that you don't even need another queue/thread to avoid blocking the main thread. It's lightweight in the sense that the user does not have to deal with how the connection is accessed.

But yes, the whole thing could probably be rethought at some point.

gentlee commented 3 years ago

@jberkel you don't understand what you are talking about. That explains a lot.

jberkel commented 3 years ago

Listen, nobody is forcing you to use this library. If you don't agree with the design, use something else, there are enough alternatives, or come up with something better yourself.

But it looks like you're not really interested in helping anyway.