Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_parallel_for.c File Reference
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include "nilorea/n_thread_pool.h"
Include dependency graph for ex_parallel_for.c:

Go to the source code of this file.

Functions

static int all_ones (const int *items, size_t count)
 every item is exactly one
static void bump (size_t begin, size_t end, void *user)
 add one to each item of the slice, so a slice done twice shows as a 2
static void expect_true (const char *what, int ok)
 report a check
int main (void)
static void * nested (void *arg)
 a loop run from another thread, as a pool worker would

Variables

static int failures = 0
 count of failed checks

Function Documentation

◆ all_ones()

int all_ones ( const int * items,
size_t count )
static

every item is exactly one

Examples
ex_parallel_for.c.

Definition at line 50 of file ex_parallel_for.c.

Referenced by main().

Here is the caller graph for this function:

◆ bump()

void bump ( size_t begin,
size_t end,
void * user )
static

add one to each item of the slice, so a slice done twice shows as a 2

Examples
ex_parallel_for.c.

Definition at line 36 of file ex_parallel_for.c.

Referenced by main(), and nested().

Here is the caller graph for this function:

◆ expect_true()

void expect_true ( const char * what,
int ok )
static

report a check

Definition at line 28 of file ex_parallel_for.c.

References failures, LOG_ERR, and n_log.

◆ main()

int main ( void )

Definition at line 58 of file ex_parallel_for.c.

References all_ones(), bump(), expect_true(), failures, get_nb_cpu_cores(), LOG_NOTICE, n_log, n_parallel_for(), nested(), and set_log_level().

Here is the call graph for this function:

◆ nested()

void * nested ( void * arg)
static

a loop run from another thread, as a pool worker would

Examples
ex_parallel_for.c.

Definition at line 44 of file ex_parallel_for.c.

References bump(), and n_parallel_for().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ failures

int failures = 0
static

count of failed checks

Definition at line 25 of file ex_parallel_for.c.