# Jobs and Tasks

**URL:** <https://forums.swift.org/t/jobs-and-tasks/53957>\
**Category:** Using Swift\
**Tags:** concurrency\
**Created:** [December 9, 2021, 2:06pm UTC](https://forums.swift.org/t/jobs-and-tasks/53957 "2021-12-09T14:06:30Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Chris\_Eidhof](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/chris_eidhof/32/1218_2.png) [@Chris\_Eidhof](https://forums.swift.org/u/Chris_Eidhof)\
**Post date:** [December 9, 2021, 2:06pm UTC](https://forums.swift.org/t/jobs-and-tasks/53957/1 "2021-12-09T14:06:30Z")

</div>

Hi everyone,

I've been wondering a bit about jobs within the new concurrency system. Let's imagine two functions:

```swift
func foo() async {
  // do some sync work
  let x = await getCachedValue()
  // do some more work
}

func getCachedValue() async -> Int {
   if let x = cache { return x }
   await compute() // ..
}

```

Let's say `foo` starts executing. As per the structured concurrency proposal, it executes in a job. Now `foo` arrives at the suspension point and wants to call `getCachedValue`. For simplicity, let's assume `getCachedValue` is not an actor method. What happens during the call? I know `foo` will be suspended, but will the current job also be suspended? I imagine one of these two scenarios would happen:

(A) A new job is created for the call to `getCachedValue`. If a new job is created, does that mean that other jobs can potentially execute in between?  
(B) The call itself is potentially still part of the same job, and the current job is only suspended when `getCachedValue` needs to suspend (e.g. because of `compute`).

In other words, once I have a cached value, is the `getCachedValue()` call essentially the same as a normal function call?

---

_[View the full topic](https://forums.swift.org/t/jobs-and-tasks/53957)._
