more message changes
[vg.git] / vg_async.h
index 190b5a8271552ae1dae6ff71646a45febca94b82..c142ad81e247967c33e853921f678b2d8e1be2ea 100644 (file)
@@ -40,7 +40,6 @@ VG_STATIC enum engine_status _vg_engine_status(void);
 VG_STATIC vg_async_item *vg_async_alloc( u32 size )
 {
    /* ditch out here if engine crashed. this serves as the 'quit checking' */
-
    if( _vg_engine_status() == k_engine_status_crashed ){
       assert( vg_thread_purpose() == k_thread_purpose_loader );
       longjmp( vg.env_loader_exit, 1 );
@@ -98,6 +97,9 @@ VG_STATIC vg_async_item *vg_async_alloc( u32 size )
    return entry;
 }
 
+/*
+ * Wait until the current stack of async calls is completely flushed out 
+ */
 VG_STATIC void vg_async_stall(void)
 {
    vg_info( "async_stall: %d\n", SDL_SemValue( vg_async.sem_wait_for_flush ) );
@@ -118,6 +120,18 @@ VG_STATIC void vg_async_dispatch( vg_async_item *item,
    SDL_AtomicUnlock( &vg_async.sl_index );
 }
 
+/*
+ * Make a simple async call without allocating extra.
+ */
+VG_STATIC void vg_async_call( void (*runner)( void *payload, u32 size ), 
+                              void *payload, u32 size )
+{
+   vg_async_item *call = vg_async_alloc(0);
+   call->payload = payload;
+   call->size = size;
+   vg_async_dispatch( call, runner );
+}
+
 /*
  * Run as much of the async buffer as possible
  */