# Multiple operations on same instance in same game frame

**URL:** <https://qa.fmod.com/t/multiple-operations-on-same-instance-in-same-game-frame/22224>\
**Category:** FMOD Engine\
**Created:** [October 25, 2024, 11:02am UTC](https://qa.fmod.com/t/multiple-operations-on-same-instance-in-same-game-frame/22224 "2024-10-25T11:02:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mca2](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mca2/32/3177_2.png) [@mca2](https://qa.fmod.com/u/mca2)\
**Post date:** [October 25, 2024, 11:02am UTC](https://qa.fmod.com/t/multiple-operations-on-same-instance-in-same-game-frame/22224/1 "2024-10-25T11:02:34Z")

</div>

How does FMOD handle multiple calls to the same instance in the same frame? So eg assume this pseudo code is part of the game loop

```cpp
FMOD::Studio::System system;
FMOD::Studio::EventInstance instance;
instance.start();
// some code
instance.start();
// some code
instance.start();
// some code
system.update();

```

Will this be one start? or multiple starts?

And similar question for this one:

```cpp
FMOD::Studio::System system;
FMOD::Studio::EventInstance instance;
instance.start();
// some code
instance.stop();
// some code
instance.start();
instance.release();
// some code
instance.start();
// some code
instance.stop();
// some code
system.update();

```

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [October 30, 2024, 5:42am UTC](https://qa.fmod.com/t/multiple-operations-on-same-instance-in-same-game-frame/22224/2 "2024-10-30T05:42:40Z")

</div>

> [@mca2](#):
>
> How does FMOD handle multiple calls to the same instance in the same frame?

Assuming you’re running in the default asynchronous processing mode, commands will be:

1. Enqueued sequentially in the command buffer on the main thread when called
2. Submitted to the update thread when the `system.update()` is called
3. Executed on the update thread in the order the commands are present in the command buffer (i.e. calling order)

As a result, all commands enqueued _will_ be executed, even if they would be repeated in a way that isn’t observable - i.e. the instance in your first snippet will be started, then restarted twice, even if the observable outcome is just that it starts.

The instance in your second snippet will:

1. Start
2. Stop
3. Start
4. Be marked for release
5. Restart
6. Stop
7. Ultimately, release due to being in a stopped state while marked for release when the system updates

You can read more about the asynchronous processing model that Studio uses in the [Studio System Processing](https://www.fmod.com/docs/2.02/api/studio-guide.html#studio-system-processing) section of the Studio API Guide.
