threads.h File Reference

Adds structures and functions needed to support threads. More...

#include "config.h"
#include "db.h"

Include dependency graph for threads.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void init_pool (int threds_count)
 Initialize thread pool.
void add_task (void *(*start_routine)(void *), void *arg, bool prioritize=false)
 Add new task.
void lock_let (let_stat *co)
 Locks letter statistics.
void unlock_let (let_stat *co)
 Unlocks letter statistics.
void wait_for_empty ()
 Waits for empty task list.
void empty_pool ()
 Empty pool.


Detailed Description

Adds structures and functions needed to support threads.


Function Documentation

void add_task ( void *(*)(void *)  start_routine,
void *  arg,
bool  prioritize = false 
)

Add new task.

This add task into our tasklist. Tasklist is checked by threads from our pool and whenever there is a free thread, it takes one task from this list and execute it.

References CHECK_PTR, and VWPRINTF.

Referenced by empty_pool(), find_it(), and find_it_thread().

void empty_pool (  ) 

Empty pool.

This function kills all threads in pool. It's quite easy.

References add_task(), kill_thread(), and wait_for_empty().

void init_pool ( int  threds_count  ) 

Initialize thread pool.

This function initialize thread pool with threads. It creates necessary number of threads. Each thread picks up task from tasklist and execute it. Nothing less, nothing more.

References CHECK_PTR.

Referenced by main().

void lock_let ( let_stat co  ) 

Locks letter statistics.

This function locks statistics in out statistics tree. It's little bit tricky, cause I don't want to use mutexes for each letter, so I've got some weirder structure. We'll see how good idea it was.

See also:
unlock_let()

References VWPRINTF.

Referenced by bsqrs(), and fsqrs().

void unlock_let ( let_stat co  ) 

Unlocks letter statistics.

This is opposite function to my lock_let() function. Both functions are little bit ugly. But I hope that they'll work.

See also:
lock_let()

Referenced by bsqrs(), and fsqrs().

void wait_for_empty (  ) 

Waits for empty task list.

This function should block until all tasks from tasklist are done.

References VPRINTF, and VWPRINTF.

Referenced by empty_pool(), and find_it().


Generated on Sat Dec 20 11:32:18 2008 for Affisix by  doxygen 1.5.7.1