-
-
Notifications
You must be signed in to change notification settings - Fork 1
Windows, status and related locks
The classes
- window_win32
- xwindow
- window_fox
all inherit from display_window_status. This latter, display_window_status, provides:
- a mutex to be used to lock on Window's operations (usage precised below)
- a status_notifier<window_status_e> that keep track of the window's status and possibly notifies a requester about a status change.
The display_window_status's mutex is unlocked when the window is waiting for events and locked when the window is processing events. It is initially locked from the window's tread in the method start_blocking() and unlocked when the window is closing.
To be noted: we should ensure that methods like 'set_status' are only called from the window's thread.
The window's mutex can be accessed only from the lock/unlock methods from display_window_status and they are protected. The windows lives in its own thread and the other threads cannot interact with the window except in the following ways:
- wait_until_notification() method from display_window_status
- update_region_request() from display_window.
For the first method the correctness is ensured by the status_notifier. A mutex specific of status_notifier ensure that status changes and notify requests are protected.
For the second method, update_region_request(), the correctness is ensured in a platform specific way. On XWindow the window's mutex is used. On Windows the SendMessage() function from window's API is used and not mutex are needed. On window_fox the thread-safe FXGUISignal->signal() function is used.
Used when a thread has to wait for a notification from another thread. The method wait() blocks until the notification is received. The method notify() is used from the other thread to notify that the request is satisfied.
The class has a mutex which is exclusively used for the condition variable.
Keep trace of a generic status and optionally signal a requester when a specific status is achieved. It does use a notify_request to signal the condition. A mutex is used to ensure the coherence between the status and the notification to a requester.
Its method set_notify_request() check if the condition is already met, in which case it returns an appropriate return code. Otherwise return a notify_request you can wait() on for the notification.
Caveat: it can accept only one requester at once. If a requester is already registered returns an error code.