pub fn attach(&self) -> Guard {
        STORAGE.with(move |s| {
            let mut ls = s.borrow_mut();

            if unlikely(!ls.registered && ls.register_failed_times < MAX_THREAD_REGISTER_RETRY) {
                ls.registered = self.resource_tag_factory.register_local_storage(&ls);
                if !ls.registered {
                    ls.register_failed_times += 1;
                }
            }

            assert!(!ls.is_set, "nested attachment is not allowed");
            ls.attached_tag.store(Some(self.infos.clone()));
            ls.is_set = true;
            ls.summary_cur_record.reset();

            Guard {
                tag: self.infos.clone(),
            }
        })
    }
/// This method is used to provide [ResourceMeteringTag] with the ability
/// to attach to the thread local context.
///
/// When you call this method, the `ResourceMeteringTag` itself will be
/// attached to [STORAGE], and a [Guard] used to control the life of the
/// tag is returned. When the `Guard` is discarded, the tag (and other
/// fields if necessary) in `STORAGE` will be cleaned up.
///
/// [STORAGE]: crate::localstorage::STORAGE
This method is used to provide [ResourceMeteringTag] with the ability
to attach to the thread local context.

When you call this method, the `ResourceMeteringTag` itself will be
attached to [STORAGE], and a [Guard] used to control the life of the
tag is returned. When the `Guard` is discarded, the tag (and other
fields if necessary) in `STORAGE` will be cleaned up.


This method is used to provide [ ResourceMeteringTag ] with the ability to attach to the thread local context . When you call this method the ` ResourceMeteringTag ` itself will be attached to [ STORAGE ] and a [ Guard ] used to control the life of the tag is returned . When the ` Guard ` is discarded the tag ( and other fields if necessary ) in ` STORAGE ` will be cleaned up .
pub fn attach(&self) -> Guard {
        STORAGE.with(move |s| {
            let mut ls = s.borrow_mut();
            if unlikely(!ls.registered && ls.register_failed_times < MAX_THREAD_REGISTER_RETRY) {
                ls.registered = self.resource_tag_factory.register_local_storage(&ls);
                if !ls.registered {
                    ls.register_failed_times += 1;
                }
            }
            assert!(!ls.is_set, "nested attachment is not allowed");
            ls.attached_tag.store(Some(self.infos.clone()));
            ls.is_set = true;
            ls.summary_cur_record.reset();
            Guard {
                tag: self.infos.clone(),
            }
        })
    }
pub fn attach ( & self ) -> Guard { STORAGE . with ( move | s | { let mut ls = s . borrow_mut ( ) ; if unlikely ( ! ls . registered && ls . register_failed_times < MAX_THREAD_REGISTER_RETRY ) { ls . registered = self . resource_tag_factory . register_local_storage ( & ls ) ; if ! ls . registered { ls . register_failed_times += 1 ; } } assert ! ( ls is_set " " ) ; ls . attached_tag . store ( Some ( self . infos . clone ( ) ) ) ; ls . is_set = true ; ls . summary_cur_record . reset ( ) ; Guard { tag : self . infos . clone ( ) , } } ) }
This method is used to provide [ResourceMeteringTag] with the ability
to attach to the thread local context.
This method is used to provide [ ResourceMeteringTag ] with the ability to attach to the thread local context .
&self
&self