SocketHandle

Struct SocketHandle 

Source
pub struct SocketHandle<S: Socket>(/* private fields */);
Expand description

Tcp连接句柄

Implementations§

Source§

impl<S: Socket> SocketHandle<S>

Source

pub fn new(image: SocketImage<S>) -> Self

构建Tcp连接句柄

Source

pub fn is_closed(&self) -> bool

线程安全的判断连接是否关闭

Source

pub fn get_token(&self) -> &Token

线程安全的获取连接令牌

Source

pub fn get_uid(&self) -> usize

线程安全的获取连接令牌

Source

pub fn get_local(&self) -> &SocketAddr

线程安全的获取连接本地地址

Source

pub fn get_remote(&self) -> &SocketAddr

线程安全的获取连接远端地址

Source

pub fn set_timeout(&self, timeout: usize, event: SocketEvent)

线程安全的设置超时定时器

Source

pub fn unset_timeout(&self)

线程安全的取消超时定时器

Source

pub fn is_security(&self) -> bool

线程安全的判断是否是安全连接

Source

pub fn get_context(&self) -> Rc<UnsafeCell<SocketContext>>

线程安全的获取Tcp连接上下文的只读引用

Source

pub fn read_ready(&self, size: usize) -> GenResult<AsyncValue<usize>, usize>

线程安全的准备读

Source

pub fn get_read_buffer(&self) -> Rc<UnsafeCell<Option<BytesMut>>>

线程安全的获取连接的接收缓冲区的引用

Source

pub fn write_ready<B>(&self, buf: B) -> Result<()>
where B: AsRef<[u8]> + 'static,

线程安全的写

Source

pub fn reregister_interest(&self, ready: Ready) -> Result<()>

重新注册当前流感兴趣的事件

Source

pub fn run_hibernated_tasks(&self)

线程安全的开始执行连接休眠时加入的任务,当前任务执行完成后自动执行下一个任务,直到任务队列为空

Source

pub fn hibernate( &self, handle: SocketHandle<S>, ready: Ready, ) -> Option<Hibernate<S>>

线程安全的异步休眠当前连接,直到被唤醒

Source

pub fn set_hibernate(&self, hibernate: Hibernate<S>) -> bool

线程安全的设置当前连接的休眠对象

Source

pub fn wakeup(&self, result: Result<()>) -> bool

线程安全的非阻塞的唤醒被休眠的当前连接,如果当前连接未被休眠,则忽略 还会唤醒当前连接正在休眠时,当前连接的所有其它休眠对象的唤醒器 唤醒过程可能会被阻塞,这不会导致线程阻塞而是返回假,调用者可以继续尝试唤醒,直到返回真

Source

pub fn close(&self, reason: Result<()>) -> Result<()>

线程安全的关闭连接

Trait Implementations§

Source§

impl<S: Socket> Clone for SocketHandle<S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Socket> Drop for SocketHandle<S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<S: Socket> Send for SocketHandle<S>

Source§

impl<S: Socket> Sync for SocketHandle<S>

Auto Trait Implementations§

§

impl<S> Freeze for SocketHandle<S>

§

impl<S> !RefUnwindSafe for SocketHandle<S>

§

impl<S> Unpin for SocketHandle<S>

§

impl<S> !UnwindSafe for SocketHandle<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ThreadSend for T
where T: Send,

Source§

impl<T> ThreadSync for T
where T: Sync + Send,