You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
946 B
36 lines
946 B
#pragma once
|
|
|
|
#include <assert.h>
|
|
#include <stddef.h>
|
|
|
|
#include "panic.h"
|
|
#include "sandbox_state.h"
|
|
#include "sandbox_set_as_complete.h"
|
|
|
|
/**
|
|
* Conditionally triggers appropriate state changes for exiting sandboxes
|
|
* @param exiting_sandbox - The sandbox that ran to completion
|
|
*/
|
|
static inline void
|
|
sandbox_exit(struct sandbox *exiting_sandbox)
|
|
{
|
|
assert(exiting_sandbox != NULL);
|
|
|
|
switch (exiting_sandbox->state) {
|
|
case SANDBOX_RETURNED:
|
|
/*
|
|
* We draw a distinction between RETURNED and COMPLETED because a sandbox cannot add itself to the
|
|
* completion queue
|
|
* TODO: I think this executes when running inside the sandbox, as it hasn't yet yielded
|
|
*/
|
|
sandbox_set_as_complete(exiting_sandbox, SANDBOX_RETURNED);
|
|
break;
|
|
case SANDBOX_BLOCKED:
|
|
case SANDBOX_ERROR:
|
|
break;
|
|
default:
|
|
panic("Cooperatively switching from a sandbox in a non-terminal %s state\n",
|
|
sandbox_state_stringify(exiting_sandbox->state));
|
|
}
|
|
}
|