+captive_shared_cache_map_flush_all()
authorshort <>
Sat, 6 Dec 2003 15:10:30 +0000 (15:10 +0000)
committershort <>
Sat, 6 Dec 2003 15:10:30 +0000 (15:10 +0000)
src/libcaptive/cc/sharedcachemap.c
src/libcaptive/cc/sharedcachemap.h

index 6f8bfcf..0a36031 100644 (file)
@@ -881,6 +881,58 @@ CaptiveSharedCacheMapObject_page *page;
        return flushed;
 }
 
+static void captive_shared_cache_map_flush_all_foreach_flush(
+               CaptiveSharedCacheMapObject *captive_shared_cache_map_object,  /* key */
+               CaptiveSharedCacheMapObject *captive_shared_cache_map_object_value,  /* value */
+               gboolean user_data)     /* unused */
+{
+       g_return_if_fail(CAPTIVE_SHARED_CACHE_MAP_IS_OBJECT(captive_shared_cache_map_object));
+       g_return_if_fail(captive_shared_cache_map_object==captive_shared_cache_map_object_value);
+
+       captive_shared_cache_map_flush(captive_shared_cache_map_object,0,G_MAXUINT64-1);        /* '-1' for overflow safety */
+}
+
+static void captive_shared_cache_map_flush_all_foreach_check(
+               CaptiveSharedCacheMapObject *captive_shared_cache_map_object,  /* key */
+               CaptiveSharedCacheMapObject *captive_shared_cache_map_object_value,  /* value */
+               gboolean user_data)     /* unused */
+{
+guint64 start,end;
+guint64 now;
+
+       g_return_if_fail(CAPTIVE_SHARED_CACHE_MAP_IS_OBJECT(captive_shared_cache_map_object));
+       g_return_if_fail(captive_shared_cache_map_object==captive_shared_cache_map_object_value);
+
+       start=0;
+       end=CAPTIVE_ROUND_UP64(captive_shared_cache_map_object->AllocationSize,PAGE_SIZE);
+
+       start=CAPTIVE_ROUND_DOWN64(start,PAGE_SIZE);
+       end=CAPTIVE_ROUND_UP64(end,PAGE_SIZE);
+
+       /* We were calling W32 code - recheck our task completion. */
+       for (now=start;now<end;now+=PAGE_SIZE) {
+CaptiveSharedCacheMapObject_page *page;
+
+               page=captive_shared_cache_map_object->pages+now/PAGE_SIZE;
+               if (!page->data_valid)
+                       continue;
+               g_assert(!page->dirty);
+               }
+}
+
+void captive_shared_cache_map_flush_all(void)
+{
+       CaptiveSharedCacheMapObject_hash_init();
+       g_hash_table_foreach(
+                       CaptiveSharedCacheMapObject_hash,       /* hash_table */
+                       (GHFunc)captive_shared_cache_map_flush_all_foreach_flush,       /* func */
+                       NULL);  /* user_data; unused */
+       g_hash_table_foreach(
+                       CaptiveSharedCacheMapObject_hash,       /* hash_table */
+                       (GHFunc)captive_shared_cache_map_flush_all_foreach_check,       /* func */
+                       NULL);  /* user_data; unused */
+}
+
 static void captive_shared_cache_map_is_any_dirty_foreach(
                CaptiveSharedCacheMapObject *captive_shared_cache_map_object,  /* key */
                CaptiveSharedCacheMapObject *captive_shared_cache_map_object_value,  /* value */
index a3737b5..9c0e309 100644 (file)
@@ -70,6 +70,7 @@ void captive_shared_cache_map_set_FlushToLsnRoutine
                (CaptiveSharedCacheMapObject *captive_shared_cache_map_object,PFLUSH_TO_LSN FlushToLsnRoutine);
 guint64 captive_shared_cache_map_flush(CaptiveSharedCacheMapObject *captive_shared_cache_map_object,
                guint64 start,guint64 end);
+void captive_shared_cache_map_flush_all(void);
 gboolean captive_shared_cache_map_is_any_dirty(void);
 gint64 captive_shared_cache_map_CcGetDirtyPages(PDIRTY_PAGE_ROUTINE DirtyPageRoutine,VOID *Context1,VOID *Context2);
 gpointer captive_shared_cache_map_get_buffer(CaptiveSharedCacheMapObject *captive_shared_cache_map_object);