public static function process_writes($writes)
    {
        foreach ($writes as $write) {
            // For every index
            foreach (FullTextSearch::get_indexes() as $index => $instance) {
                // If that index as a field from this class
                if (SearchIntrospection::is_subclass_of($write['class'], $instance->dependancyList)) {
                    // Get the dirty IDs
                    $dirtyids = $instance->getDirtyIDs($write['class'], $write['id'], $write['statefulids'], $write['fields']);

                    // Then add then then to the global list to deal with later
                    foreach ($dirtyids as $dirtyclass => $ids) {
                        if ($ids) {
                            if (!self::$processor) {
                                self::$processor = Injector::inst()->create(SearchUpdateImmediateProcessor::class);
                            }
                            self::$processor->addDirtyIDs($dirtyclass, $ids, $index);
                        }
                    }
                }
            }
        }

        // If we do have some work to do register the shutdown function to actually do the work
        if (self::$processor && !self::$registered && self::config()->get('flush_on_shutdown')) {
            register_shutdown_function(array(SearchUpdater::class, "flush_dirty_indexes"));
            self::$registered = true;
        }
    }