Skip to content

Commit 947af15

Browse files
committed
fix(runtime): add header of send_wrapper and inline all fns
1 parent 5fd88c6 commit 947af15

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

compio-runtime/src/runtime/send_wrapper.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
// Copyright 2017 Thomas Keh.
2+
// Copyright 2024 compio-rs
3+
//
4+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7+
// option. This file may not be copied, modified, or distributed
8+
// except according to those terms.
9+
110
use std::{
211
cell::Cell,
312
mem::{self, ManuallyDrop},
@@ -17,6 +26,7 @@ pub struct SendWrapper<T> {
1726
impl<T> SendWrapper<T> {
1827
/// Create a `SendWrapper<T>` wrapper around a value of type `T`.
1928
/// The wrapper takes ownership of the value.
29+
#[inline]
2030
pub fn new(data: T) -> SendWrapper<T> {
2131
SendWrapper {
2232
data: ManuallyDrop::new(data),
@@ -26,6 +36,7 @@ impl<T> SendWrapper<T> {
2636

2737
/// Returns `true` if the value can be safely accessed from within the
2838
/// current thread.
39+
#[inline]
2940
pub fn valid(&self) -> bool {
3041
self.thread_id == THREAD_ID.get()
3142
}
@@ -35,11 +46,13 @@ impl<T> SendWrapper<T> {
3546
/// # Safety
3647
///
3748
/// The caller should be in the same thread as the creator.
49+
#[inline]
3850
pub unsafe fn get_unchecked(&self) -> &T {
3951
&self.data
4052
}
4153

4254
/// Returns a reference to the contained value, if valid.
55+
#[inline]
4356
pub fn get(&self) -> Option<&T> {
4457
if self.valid() { Some(&self.data) } else { None }
4558
}

0 commit comments

Comments
 (0)