replace VG_STATIC -> static
[vg.git] / vg_async.h
index c142ad81e247967c33e853921f678b2d8e1be2ea..7537aae1e839e5a99aa08f445d9b5efbf54aab81 100644 (file)
@@ -9,6 +9,7 @@
 
 #define VG_GAME
 #include "vg/vg.h"
+static void vg_assert_thread( enum vg_thread_purpose required );
 
 typedef struct vg_async_item vg_async_item;
 
@@ -31,13 +32,13 @@ struct vg_async{
 }
 static vg_async;
 
-VG_STATIC enum vg_thread_purpose vg_thread_purpose(void);
-VG_STATIC enum engine_status _vg_engine_status(void);
+static enum vg_thread_purpose vg_thread_purpose(void);
+static enum engine_status _vg_engine_status(void);
 
 /*
  * Allocate an asynchronous call with a bit of memory
  */
-VG_STATIC vg_async_item *vg_async_alloc( u32 size )
+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 ){
@@ -100,8 +101,9 @@ VG_STATIC vg_async_item *vg_async_alloc( u32 size )
 /*
  * Wait until the current stack of async calls is completely flushed out 
  */
-VG_STATIC void vg_async_stall(void)
+static void vg_async_stall(void)
 {
+   vg_assert_thread(k_thread_purpose_loader);
    vg_info( "async_stall: %d\n", SDL_SemValue( vg_async.sem_wait_for_flush ) );
    SDL_SemWait( vg_async.sem_wait_for_flush );
 }
@@ -109,9 +111,10 @@ VG_STATIC void vg_async_stall(void)
 /*
  * Mark the call as being filled and ready to go
  */
-VG_STATIC void vg_async_dispatch( vg_async_item *item, 
+static void vg_async_dispatch( vg_async_item *item, 
                                   void (*runner)( void *payload, u32 size ) )
 {
+   vg_assert_thread(k_thread_purpose_loader);
    if( SDL_SemValue(vg_async.sem_wait_for_flush) )
       SDL_SemWait(vg_async.sem_wait_for_flush);
 
@@ -123,9 +126,10 @@ VG_STATIC void vg_async_dispatch( vg_async_item *item,
 /*
  * Make a simple async call without allocating extra.
  */
-VG_STATIC void vg_async_call( void (*runner)( void *payload, u32 size ), 
+static void vg_async_call( void (*runner)( void *payload, u32 size ), 
                               void *payload, u32 size )
 {
+   vg_assert_thread(k_thread_purpose_loader);
    vg_async_item *call = vg_async_alloc(0);
    call->payload = payload;
    call->size = size;
@@ -135,7 +139,7 @@ VG_STATIC void vg_async_call( void (*runner)( void *payload, u32 size ),
 /*
  * Run as much of the async buffer as possible
  */
-VG_STATIC void vg_run_async_checked(void)
+static void vg_run_async_checked(void)
 {
    SDL_AtomicLock( &vg_async.sl_index );
 
@@ -171,7 +175,7 @@ VG_STATIC void vg_run_async_checked(void)
    SDL_AtomicUnlock( &vg_async.sl_index );
 }
 
-VG_STATIC void vg_async_init(void)
+static void vg_async_init(void)
 {
    vg_async.sem_wait_for_flush = SDL_CreateSemaphore(0);
    vg_async.buffer = vg_create_linear_allocator( NULL, 50*1024*1024,