hashmismatch / freertos.rs

A Rust wrapper for FreeRTOS.
232 stars 22 forks source link

Added uninitialized for Queue #32

Open Neo-Zhixing opened 4 years ago

Neo-Zhixing commented 4 years ago

Certain functions in ESP-IDR (for example uart_driver_install ) asks for an uninitialized Queue pointer. This creates an additional method in Queue to creates an uninitialized queue so that they could be initialized by something else.

rudib commented 4 years ago

What else could then initialize this queue since the field member holding the pointer to the queue is private?

If this is really needed (and this goes for other FreeRTOS.rs wrappers as well), I'd much prefer to have a constructor API that mimics those from Rust's stdlib:

pub unsafe fn from_raw(ptr: FreeRtosQueueHandle) -> Result<Self, FreeRtosError> {
  // .,..
}

Optionally, this method could also do a sanity check by calling a peek or count method on the queue.