2013-12-11 23:15:37 +01:00
2014-03-14 20:46:20 +01:00
2014-03-14 20:46:20 +01:00
2014-03-14 20:38:10 +01:00
2014-01-17 12:02:29 -08:00
2013-12-12 15:29:59 +01:00
2014-01-17 21:18:59 +01:00

workdispatcher

A little library in C for managing task with operations via an operation queue interface.

Documentation

This project uses doxygen (http://www.stack.nl/~dimitri/doxygen/index.html) for the code documentation. Just point doxygen to the doc/Doxyfile and the html documentation will be generated.

Command line exemple :

cd doc
doxygen Doxyfile

Dependencies

This library uses libmemorymanagement internally.

Usage

An example of code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "operationQueue.h"
#include <memory_management/memory_management.h>

#define ITER 10

void opf(WDOperation *operation, void *arg);

int main () {
	char *string = "Hello world";
	
	// Create the operation queue
	WDOperationQueue *operationQueue = WDOperationQueueAllocate();
	// Set a name (for debugging)
	WDOperationQueueSetName(operationQueue, "queue.name");
	
	// Add ITER operations to the queue that execute the function opf with string as argument
	for (unsigned int i=0; i<ITER; i++) {
		WDOperation *operation = WDOperationAllocate(opf, string);
		WDOperationQueueAddOperation(operationQueue, operation);
		// related to libmemorymanagement
		release(operation);
	}
	
	// Block until all operations are finished
	WDOperationQueueWaitAllOperations(operationQueue);
	
	// memory management
	release(operationQueue);
	return 0;
}

// Operation's function
void opf(WDOperation *operation, void *arg) {
	static int i=0;
	char *string = arg;
	sleep(1);
	puts(string);
	
	// print the operation's queue name
	WDOperationQueue *queue = WDOperationCurrentOperationQueue(operation);
	puts(WDOperationQueueGetName(queue));
	
	// Add some more operations to the queue, why not?
	if (i++<ITER) {
		WDOperation *operation = WDOperationAllocate(opf, string);
		WDOperationQueueAddOperation(queue, operation);
		release(operation);
	}
	return;
}

Description
A little library in C for managing task with operations via an operation queue interface.
Readme MIT 95 KiB
Languages
C 90%
Makefile 10%