github.com/aclements/go-misc@v0.0.0-20240129233631-2f6ede80790c/go-weave/weave/tls.go (about)

     1  // Copyright 2017 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package weave
     6  
     7  type TLS struct {
     8  	_ byte
     9  }
    10  
    11  func NewTLS() *TLS {
    12  	return &TLS{}
    13  }
    14  
    15  func (v *TLS) Get() interface{} {
    16  	return globalSched.curThread.tls[v]
    17  }
    18  
    19  func (v *TLS) Set(val interface{}) {
    20  	m := globalSched.curThread.tls
    21  	if m == nil {
    22  		m = make(map[*TLS]interface{})
    23  		globalSched.curThread.tls = m
    24  	}
    25  	m[v] = val
    26  }