I need to implement command queue in my application, nothing special. Several threads can put commands to queue, one dedicated thread dispatches them; if queue is overflowed - thread willing to put command should wait.
I analyzed code of ChibiOS-GFX (great work!), and I found that mailbox functionality used there - to send commands like DrawChar. All the putting and fetching is wrapped with semaphores and mutexes.
As far as I understand (please correct me if I am wrong), to use mailbox, one should implement an array for messages msg_t, and an array for commands themselves. To put command to queue, one should find empty slot in command array, get pointer and put it into mailbox. To fetch command, one should fetch pointer from mailbox.
What is the advantage of mailbox over simple circular buffer of commands? It seems to me that wrapping mailbox and it's methods requires more code (and memory), than implementing circular buffer from scratch. Most probably, I do not know something (maybe obvious). Would you comment please?