Blame source/uds/chapterWriter.h

Packit b55c50
/*
Packit b55c50
 * Copyright (c) 2020 Red Hat, Inc.
Packit b55c50
 *
Packit b55c50
 * This program is free software; you can redistribute it and/or
Packit b55c50
 * modify it under the terms of the GNU General Public License
Packit b55c50
 * as published by the Free Software Foundation; either version 2
Packit b55c50
 * of the License, or (at your option) any later version.
Packit b55c50
 * 
Packit b55c50
 * This program is distributed in the hope that it will be useful,
Packit b55c50
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit b55c50
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit b55c50
 * GNU General Public License for more details.
Packit b55c50
 * 
Packit b55c50
 * You should have received a copy of the GNU General Public License
Packit b55c50
 * along with this program; if not, write to the Free Software
Packit b55c50
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit b55c50
 * 02110-1301, USA. 
Packit b55c50
 *
Packit b55c50
 * $Id: //eng/uds-releases/jasper/src/uds/chapterWriter.h#2 $
Packit b55c50
 */
Packit b55c50
Packit b55c50
#ifndef CHAPTER_WRITER_H
Packit b55c50
#define CHAPTER_WRITER_H
Packit b55c50
Packit b55c50
#include "atomicDefs.h"
Packit b55c50
#include "indexVersion.h"
Packit b55c50
#include "openChapterZone.h"
Packit b55c50
Packit b55c50
typedef struct chapterWriter ChapterWriter;
Packit b55c50
Packit b55c50
// This opaque declaration breaks the dependency loop with index.h
Packit b55c50
struct index;
Packit b55c50
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Create a chapter writer and start its thread.
Packit b55c50
 *
Packit b55c50
 * @param index         the index containing the chapters to be written
Packit b55c50
 * @param indexVersion  the index version parameters
Packit b55c50
 * @param writerPtr     pointer to hold the new writer
Packit b55c50
 *
Packit b55c50
 * @return           UDS_SUCCESS or an error code
Packit b55c50
 **/
Packit b55c50
int makeChapterWriter(struct index                *index,
Packit b55c50
                      const struct index_version  *indexVersion,
Packit b55c50
                      ChapterWriter              **writerPtr)
Packit b55c50
  __attribute__((warn_unused_result));
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Free a chapter writer, waiting for its thread to finish.
Packit b55c50
 *
Packit b55c50
 * @param writer  the chapter writer to destroy
Packit b55c50
 **/
Packit b55c50
void freeChapterWriter(ChapterWriter *writer);
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Asychronously close and write a chapter by passing it to the writer
Packit b55c50
 * thread. Writing won't start until all zones have submitted a chapter.
Packit b55c50
 *
Packit b55c50
 * @param writer     the chapter writer
Packit b55c50
 * @param zoneNumber the number of the zone submitting a chapter
Packit b55c50
 * @param chapter    the chapter to write
Packit b55c50
 *
Packit b55c50
 * @return The number of zones which have submitted the current chapter
Packit b55c50
 **/
Packit b55c50
unsigned int startClosingChapter(ChapterWriter   *writer,
Packit b55c50
                                 unsigned int     zoneNumber,
Packit b55c50
                                 OpenChapterZone *chapter)
Packit b55c50
  __attribute__((warn_unused_result));
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Wait for the chapter writer thread to finish closing the chapter previous
Packit b55c50
 * to the one specified.
Packit b55c50
 *
Packit b55c50
 * @param writer               the chapter writer
Packit b55c50
 * @param currentChapterNumber the currentChapter number
Packit b55c50
 *
Packit b55c50
 * @return UDS_SUCCESS or an error code from the most recent write
Packit b55c50
 *         request
Packit b55c50
 **/
Packit b55c50
int finishPreviousChapter(ChapterWriter *writer, uint64_t currentChapterNumber)
Packit b55c50
  __attribute__((warn_unused_result));
Packit b55c50
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Wait for the chapter writer thread to finish all writes to storage.
Packit b55c50
 *
Packit b55c50
 * @param writer  the chapter writer
Packit b55c50
 **/
Packit b55c50
void waitForIdleChapterWriter(ChapterWriter *writer);
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Stop the chapter writer and wait for it to finish.
Packit b55c50
 *
Packit b55c50
 * @param writer  the chapter writer to stop
Packit b55c50
 *
Packit b55c50
 * @return UDS_SUCCESS or an error code from the most recent write
Packit b55c50
 *         request
Packit b55c50
 **/
Packit b55c50
int stopChapterWriter(ChapterWriter *writer)
Packit b55c50
  __attribute__((warn_unused_result));
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Get the number of bytes allocated for the chapter writer.
Packit b55c50
 *
Packit b55c50
 * @param writer the chapter writer
Packit b55c50
 *
Packit b55c50
 * @return the number of bytes allocated
Packit b55c50
 **/
Packit b55c50
size_t getChapterWriterMemoryAllocated(ChapterWriter *writer);
Packit b55c50
Packit b55c50
#endif /* CHAPTER_WRITER_H */