From 15bbaceb329d1ac98375f3c1c13a17b99c2bc627 Mon Sep 17 00:00:00 2001 From: Anthony Deschamps Date: Sun, 4 Nov 2018 22:54:40 -0500 Subject: [PATCH] Impl Send and Sync for Controller. --- src/controller/controller.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/controller/controller.rs b/src/controller/controller.rs index d0c16b9..741b96d 100644 --- a/src/controller/controller.rs +++ b/src/controller/controller.rs @@ -11,6 +11,16 @@ pub struct Controller { c_struct: ws2811_t, } +/// It is safe to implement `Send` because `Controller` is the sole +/// owner of its internal `ws2811_t` object and the pointers it +/// contains, and those pointers are never exposed by this module's +/// API. Therefore, there is no risk of pointer aliasing. +unsafe impl Send for Controller {} + +/// It is safe to implement `Sync` because the underlying `ws2811_t` +/// struct does not make use of any interior mutability. +unsafe impl Sync for Controller {} + impl Controller { /// Creates a new Controller ///