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