基于https://proandroiddev.com/demystifying-coroutinecontext-1ce5b68407ad,我编写了我的参考类: class MyElement(overrideval key: CoroutineContext.Key<*>, val value: String) : CoroutineContext.Element
class MyKey: CoroutineContext.Key[MyKey()] /
我在网上读过几篇文章,包括这篇文章-- --但我仍然对如何访问当前上下文中的协同元素感到有点困惑。这是让我困惑的部分。使用顶层挂起coroutineContext只读属性可以获得当前上下文中的元素。println("Running in ${coroutineContext[CoroutineName]}")
在本例中,CoroutineName是对映射到CoroutineName元素的键的引用我了解到,get方法在coroutine
我需要一些来自我的控制器协同线中的头的参数,并将它们作为请求的关联id记录下来。我知道网络流量可以使用WebFilter来拦截和记录它们,或者修改它们,但是它能被发送到它将触发的协同线吗?class ItemController(private val itemRepository: ItemRepository) {
suspend fun findAllItems(): List&