refactor: sandbox struct in req queue

master
Sean McBride 3 years ago
parent ee760577ed
commit 362bf39047

@ -5,7 +5,7 @@
#include "sandbox_types.h" #include "sandbox_types.h"
/* Returns pointer back if successful, null otherwise */ /* Returns pointer back if successful, null otherwise */
typedef struct sandbox *(*global_request_scheduler_add_fn_t)(void *); typedef struct sandbox *(*global_request_scheduler_add_fn_t)(struct sandbox *);
typedef int (*global_request_scheduler_remove_fn_t)(struct sandbox **); typedef int (*global_request_scheduler_remove_fn_t)(struct sandbox **);
typedef int (*global_request_scheduler_remove_if_earlier_fn_t)(struct sandbox **, uint64_t); typedef int (*global_request_scheduler_remove_if_earlier_fn_t)(struct sandbox **, uint64_t);
typedef uint64_t (*global_request_scheduler_peek_fn_t)(void); typedef uint64_t (*global_request_scheduler_peek_fn_t)(void);

@ -5,7 +5,7 @@
/* Default uninitialized implementations of the polymorphic interface */ /* Default uninitialized implementations of the polymorphic interface */
noreturn static struct sandbox * noreturn static struct sandbox *
uninitialized_add(void *arg) uninitialized_add(struct sandbox *arg)
{ {
panic("Global Request Scheduler Add was called before initialization\n"); panic("Global Request Scheduler Add was called before initialization\n");
} }

@ -15,16 +15,16 @@ static struct priority_queue *global_request_scheduler_minheap;
* @returns pointer to request if added. Panics runtime otherwise * @returns pointer to request if added. Panics runtime otherwise
*/ */
static struct sandbox * static struct sandbox *
global_request_scheduler_minheap_add(void *sandbox_raw) global_request_scheduler_minheap_add(struct sandbox *sandbox)
{ {
assert(sandbox_raw); assert(sandbox);
assert(global_request_scheduler_minheap); assert(global_request_scheduler_minheap);
if (unlikely(!listener_thread_is_running())) panic("%s is only callable by the listener thread\n", __func__); if (unlikely(!listener_thread_is_running())) panic("%s is only callable by the listener thread\n", __func__);
int return_code = priority_queue_enqueue(global_request_scheduler_minheap, sandbox_raw); int return_code = priority_queue_enqueue(global_request_scheduler_minheap, sandbox);
/* TODO: Propagate -1 to caller. Issue #91 */ /* TODO: Propagate -1 to caller. Issue #91 */
if (return_code == -ENOSPC) panic("Request Queue is full\n"); if (return_code == -ENOSPC) panic("Request Queue is full\n");
return (struct sandbox *)sandbox_raw; return sandbox;
} }
/** /**

Loading…
Cancel
Save