createrepo_c library 1.1.0
C library for metadata manipulation
Loading...
Searching...
No Matches
Useful thread function to use in GThreadPool.

Data Structures

struct  cr_CompressionTask
 
struct  cr_RepomdRecordFillTask
 

Functions

cr_CompressionTaskcr_compressiontask_new (const char *src, const char *dst, cr_CompressionType compression_type, cr_ChecksumType checksum_type, const char *zck_dict_dir, gboolean zck_auto_chunk, int delsrc, GError **err)
 
void cr_compressiontask_free (cr_CompressionTask *task, GError **err)
 
void cr_compressing_thread (gpointer data, gpointer user_data)
 
cr_RepomdRecordFillTaskcr_repomdrecordfilltask_new (cr_RepomdRecord *record, cr_ChecksumType checksum_type, GError **err)
 
void cr_repomdrecordfilltask_free (cr_RepomdRecordFillTask *task, GError **err)
 
void cr_repomd_record_fill_thread (gpointer data, gpointer user_data)
 
void cr_rewrite_pkg_count_thread (gpointer data, gpointer user_data)
 

Detailed Description

Paralelized compression example:

cr_CompressionTask *task_1, *task_2;
GThreadPool *pool;
// Prepare tasks
task_1 = cr_compressiontask_new("foo", "foo.gz", CR_CW_GZ_COMPRESSION, 1,
task_2 = cr_compressiontask_new("bar", "bar.gz", CR_CW_GZ_COMPRESSION, 1,
// Create pool for tasks
pool = g_thread_pool_new(cr_compressing_thread, NULL, 2, FALSE, NULL);
// Push tasks to the pool
g_thread_pool_push(pool, task_1, NULL);
g_thread_pool_push(pool, task_2, NULL);
// Wait until both treats finish and free the pool.
g_thread_pool_free(pool, FALSE, TRUE);
// Use results
// Do whatever you want or need to do
// Clean up
@ CR_CHECKSUM_SHA512
Definition checksum.h:53
@ CR_CHECKSUM_SHA256
Definition checksum.h:51
@ CR_CW_GZ_COMPRESSION
void cr_compressiontask_free(cr_CompressionTask *task, GError **err)
cr_CompressionTask * cr_compressiontask_new(const char *src, const char *dst, cr_CompressionType compression_type, cr_ChecksumType checksum_type, const char *zck_dict_dir, gboolean zck_auto_chunk, int delsrc, GError **err)
void cr_compressing_thread(gpointer data, gpointer user_data)

Function Documentation

◆ cr_compressing_thread()

void cr_compressing_thread ( gpointer data,
gpointer user_data )

Function for GThreadPool.

◆ cr_compressiontask_free()

void cr_compressiontask_free ( cr_CompressionTask * task,
GError ** err )

Frees cr_CompressionTask and all its components.

Parameters
taskcr_CompressionTask task
errGError **

◆ cr_compressiontask_new()

cr_CompressionTask * cr_compressiontask_new ( const char * src,
const char * dst,
cr_CompressionType compression_type,
cr_ChecksumType checksum_type,
const char * zck_dict_dir,
gboolean zck_auto_chunk,
int delsrc,
GError ** err )

Function to prepare a new cr_CompressionTask.

Parameters
srcSource filename.
dstDestination filename or NULL (then src+compression suffix will be used).
compression_typeType of compression to use.
checksum_typeChecksum type for stat calculation. Note: Stat is always use. If you don't need a stats use CR_CHECKSUM_UNKNOWN, then no checksum calculation will be performed, only size would be calculated. Don't be afraid, size calculation has almost no overhead.
delsrcDelete src after successuful compression. 0 = Do not delete, delete otherwise
errGError **. Note: This is a GError for the cr_compresiontask_new function. The GError that will be at created cr_CompressionTask is different.
Returns
New cr_CompressionTask.

◆ cr_repomd_record_fill_thread()

void cr_repomd_record_fill_thread ( gpointer data,
gpointer user_data )

Function for GThread Pool.

◆ cr_repomdrecordfilltask_free()

void cr_repomdrecordfilltask_free ( cr_RepomdRecordFillTask * task,
GError ** err )

◆ cr_repomdrecordfilltask_new()

cr_RepomdRecordFillTask * cr_repomdrecordfilltask_new ( cr_RepomdRecord * record,
cr_ChecksumType checksum_type,
GError ** err )

Function to prepare a new cr_RepomdRecordFillTask.

Parameters
recordcr_RepomdRecord.
checksum_typeType of checksum.
errGError **
Returns
New cr_RepomdRecordFillTask.

◆ cr_rewrite_pkg_count_thread()

void cr_rewrite_pkg_count_thread ( gpointer data,
gpointer user_data )

Function for GThread Pool.