Does the FLTK lock guarantee that requests are fulfilled in the order they are received? I.e. a FIFO behavior?
I don't think there's any guarantee of wake ordering, FIFO or otherwise.
It's more left to chance dependent on the OS's cpu/thread scheduling.
At least in the posix unix pthreads case; I don't know about windows.
Internally Fl::lock() in the posix unix context uses pthread_mutex_lock(), e.g.
--src/drivers/Posix/Fl_Posix_System_Driver.cxx:
static void lock_function_std() {
if (!counter || owner != pthread_self()) {
pthread_mutex_lock(&fltk_mutex);
owner = pthread_self();
}
counter++;
}
There are some caveats, as there's also a recursive lock option that adds the PTHREAD_MUTEX_RECURSIVE flag to the lock, but I don't think that affects ordering either.
The man page for pthread_mutex_lock() doesn't mention anything about queuing or ordering, so that would seem to imply that which ever thread is scheduled by the operating system to wake up after a lock release is the one that gets the lock next, which is dependent on the operating system's cpu/thread scheduling, which is basically left entirely, assuming thread priorities are equal.
See also this stackoverflow post which asks your same question, and if one needs queuing, that article references another on how to implement FIFO locking.
Oops, small correction to my last post:
[..] which is basically left entirely to chance, assuming thread priorities are equal. [..]
Also, what Ian said; I didn't see his post until just now.