You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not really sure if this is a bug or a misunderstanding on my part.
I was looking into the BatMutex and BatConcurrent modules, and noticed the following.
BatMutex provides two functions:
val make : unit -> BatConcurrent.lock
val synchronize : ?lock:Mutex.t -> ('a -> 'b) -> 'a -> 'b
Because make returns BatConcurrent.lock, you can't really use it with synchronize, i.e the following code does not typecheck:
let()=let m =BatMutex.make ()inBatMutex.synchronize ~lock:m (funx -> x) ()
Perhaps I am just not experienced enough with Batteries, but I don't understand the point of the BatMutex API.
The function synchronized cannot be used with the only other function in that module.
What is more, BatConcurrent also has a function called synchronize, but it really has a different type. BatMutex.synchronize is more like BatConcurrent.sync if I understand it correctly.
So, the following code does typecheck:
let()=let m =BatMutex.make ()inBatConcurrent.sync m (funx -> x) ()
It it a "bug" in the type of BatMutex.synchronize or am I just misunderstanding the library?
The text was updated successfully, but these errors were encountered:
You could argue that there should be a make_mutex and make_rmutex in BatConcurrent but I guess that was done this way around to avoid depending on -thread in the general case which seems to be nolock.
In many places though, including in batPervasives, the mechanism is advertised but actually not used.
This whole BatConcurrent looks unfinished, neglected, and a bad idea to begin with. If batteries internals rely on some mechanism that are non-reentrant, then they should be made safe by default and always and not require the user to first override a global ref to some nolock (that is, if he remembers about it and have time to do so in the module initialization code, and without overridding other choices made by other libraries also depending on batteries). If we want to support several mutex libraries then those modules could rely on functors and/or provide variants of those modules?
I am not really sure if this is a bug or a misunderstanding on my part.
I was looking into the
BatMutex
andBatConcurrent
modules, and noticed the following.BatMutex provides two functions:
Because
make
returnsBatConcurrent.lock
, you can't really use it withsynchronize
, i.e the following code does not typecheck:Perhaps I am just not experienced enough with Batteries, but I don't understand the point of the BatMutex API.
The function
synchronized
cannot be used with the only other function in that module.What is more,
BatConcurrent
also has a function calledsynchronize
, but it really has a different type.BatMutex.synchronize
is more likeBatConcurrent.sync
if I understand it correctly.So, the following code does typecheck:
It it a "bug" in the type of
BatMutex.synchronize
or am I just misunderstanding the library?The text was updated successfully, but these errors were encountered: