1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use ;
/// A trait for ensuring thread safety of a type by checking thread ownership.
///
/// This trait provides a mechanism to verify that a particular instance is only
/// accessed from the thread that originally created it, preventing concurrent
/// access across multiple threads.
///
/// # Panics
///
/// Calls `ensure_thread_safety()` will panic if the current thread is different
/// from the thread that owns the instance.
///
/// # Examples
///
/// ```rust
/// use std::thread::{self, ThreadId};
/// use transactional::prelude::*;
///
/// struct MyType {
/// owner_thread_id: ThreadId,
/// }
/// impl ThreadSafetyChecker for MyType {
/// fn get_owner_thread_id(&self) -> ThreadId {
/// self.owner_thread_id
/// }
/// }
/// ```
///