GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
cache1.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <grass/raster3d.h>
#include "raster3d_intern.h"
#include "cachehash.h"
Include dependency graph for cache1.c:

Go to the source code of this file.

Macros

#define IS_ACTIVE_ELT(elt)   (c->locks[elt] != 2)
 
#define IS_NOT_ACTIVE_ELT(elt)   (c->locks[elt] == 2)
 
#define IS_LOCKED_ELT(elt)   (c->locks[elt] == 1)
 
#define IS_UNLOCKED_ELT(elt)   (c->locks[elt] == 0)
 
#define IS_NOT_IN_QUEUE_ELT(elt)   (IS_LOCKED_ELT (elt))
 
#define IS_IN_QUEUE_ELT(elt)   (! IS_NOT_IN_QUEUE_ELT (elt))
 
#define DEACTIVATE_ELT(elt)
 
#define LOCK_ELT(elt)
 
#define UNLOCK_ELT(elt)
 
#define ONE_UNLOCKED_ELT_ONLY   (c->first == c->last)
 
#define ARE_MIN_UNLOCKED   (c->nofUnlocked <= c->minUnlocked)
 

Functions

void Rast3d_cache_reset (RASTER3D_cache *c)
 
void Rast3d_cache_dispose (RASTER3D_cache *c)
 
void * Rast3d_cache_new (int nofElts, int sizeOfElts, int nofNames, int(*eltRemoveFun)(), void *eltRemoveFunData, int(*eltLoadFun)(), void *eltLoadFunData)
 
void Rast3d_cache_set_remove_fun (RASTER3D_cache *c, int(*eltRemoveFun)(), void *eltRemoveFunData)
 
void Rast3d_cache_set_load_fun (RASTER3D_cache *c, int(*eltLoadFun)(), void *eltLoadFunData)
 
void * Rast3d_cache_new_read (int nofElts, int sizeOfElts, int nofNames, read_fn *eltLoadFun, void *eltLoadFunData)
 
int Rast3d_cache_lock (RASTER3D_cache *c, int name)
 
void Rast3d_cache_lock_intern (RASTER3D_cache *c, int index)
 
int Rast3d_cache_unlock (RASTER3D_cache *c, int name)
 
int Rast3d_cache_unlock_all (RASTER3D_cache *c)
 
int Rast3d_cache_lock_all (RASTER3D_cache *c)
 
void Rast3d_cache_autolock_on (RASTER3D_cache *c)
 
void Rast3d_cache_autolock_off (RASTER3D_cache *c)
 
void Rast3d_cache_set_min_unlock (RASTER3D_cache *c, int nofMinUnLocked)
 
int Rast3d_cache_remove_elt (RASTER3D_cache *c, int name)
 
int Rast3d_cache_flush (RASTER3D_cache *c, int name)
 
int Rast3d_cache_remove_all (RASTER3D_cache *c)
 
int Rast3d_cache_flush_all (RASTER3D_cache *c)
 
void * Rast3d_cache_elt_ptr (RASTER3D_cache *c, int name)
 
int Rast3d_cache_load (RASTER3D_cache *c, int name)
 
int Rast3d_cache_get_elt (RASTER3D_cache *c, int name, void *dst)
 
int Rast3d_cache_put_elt (RASTER3D_cache *c, int name, const void *src)
 
int MAIN ()
 

Macro Definition Documentation

◆ ARE_MIN_UNLOCKED

#define ARE_MIN_UNLOCKED   (c->nofUnlocked <= c->minUnlocked)

Definition at line 30 of file cache1.c.

Referenced by Rast3d_cache_elt_ptr(), and Rast3d_cache_lock().

◆ DEACTIVATE_ELT

#define DEACTIVATE_ELT (   elt)
Value:
((IS_LOCKED_ELT(elt) ? \
(c->nofUnlocked)++ : (0)), \
c->locks[elt] = 2)
#define IS_LOCKED_ELT(elt)
Definition: cache1.c:14

Definition at line 19 of file cache1.c.

◆ IS_ACTIVE_ELT

#define IS_ACTIVE_ELT (   elt)    (c->locks[elt] != 2)

Definition at line 12 of file cache1.c.

Referenced by Rast3d_cache_elt_ptr(), Rast3d_cache_flush_all(), and Rast3d_cache_remove_all().

◆ IS_IN_QUEUE_ELT

#define IS_IN_QUEUE_ELT (   elt)    (! IS_NOT_IN_QUEUE_ELT (elt))

Definition at line 17 of file cache1.c.

◆ IS_LOCKED_ELT

#define IS_LOCKED_ELT (   elt)    (c->locks[elt] == 1)

Definition at line 14 of file cache1.c.

Referenced by Rast3d_cache_lock(), Rast3d_cache_lock_intern(), and Rast3d_cache_unlock_all().

◆ IS_NOT_ACTIVE_ELT

#define IS_NOT_ACTIVE_ELT (   elt)    (c->locks[elt] == 2)

Definition at line 13 of file cache1.c.

◆ IS_NOT_IN_QUEUE_ELT

#define IS_NOT_IN_QUEUE_ELT (   elt)    (IS_LOCKED_ELT (elt))

Definition at line 16 of file cache1.c.

◆ IS_UNLOCKED_ELT

#define IS_UNLOCKED_ELT (   elt)    (c->locks[elt] == 0)

Definition at line 15 of file cache1.c.

Referenced by Rast3d_cache_elt_ptr(), Rast3d_cache_lock_all(), and Rast3d_cache_unlock().

◆ LOCK_ELT

#define LOCK_ELT (   elt)
Value:
((IS_LOCKED_ELT(elt) ? \
(0) : (c->nofUnlocked)--), \
(c->locks[elt] = 1))
#define IS_LOCKED_ELT(elt)
Definition: cache1.c:14

Definition at line 22 of file cache1.c.

◆ ONE_UNLOCKED_ELT_ONLY

#define ONE_UNLOCKED_ELT_ONLY   (c->first == c->last)

Definition at line 29 of file cache1.c.

Referenced by Rast3d_cache_elt_ptr(), and Rast3d_cache_lock().

◆ UNLOCK_ELT

#define UNLOCK_ELT (   elt)
Value:
((IS_LOCKED_ELT(elt) ? \
(c->nofUnlocked)++ : (0)), \
(c->locks[elt] = 0))
#define IS_LOCKED_ELT(elt)
Definition: cache1.c:14

Definition at line 25 of file cache1.c.

Referenced by Rast3d_cache_elt_ptr().

Function Documentation

◆ MAIN()

int MAIN ( )

Definition at line 649 of file cache1.c.

◆ Rast3d_cache_autolock_off()

void Rast3d_cache_autolock_off ( RASTER3D_cache c)

Definition at line 359 of file cache1.c.

References RASTER3D_cache::autoLock.

Referenced by Rast3d_autolock_off().

◆ Rast3d_cache_autolock_on()

void Rast3d_cache_autolock_on ( RASTER3D_cache c)

Definition at line 352 of file cache1.c.

References RASTER3D_cache::autoLock.

Referenced by Rast3d_autolock_on().

◆ Rast3d_cache_dispose()

void Rast3d_cache_dispose ( RASTER3D_cache c)

Definition at line 65 of file cache1.c.

◆ Rast3d_cache_elt_ptr()

◆ Rast3d_cache_flush()

int Rast3d_cache_flush ( RASTER3D_cache c,
int  name 
)

Definition at line 420 of file cache1.c.

Referenced by Rast3d_cache_flush_all().

◆ Rast3d_cache_flush_all()

int Rast3d_cache_flush_all ( RASTER3D_cache c)

◆ Rast3d_cache_get_elt()

int Rast3d_cache_get_elt ( RASTER3D_cache c,
int  name,
void *  dst 
)

Definition at line 527 of file cache1.c.

References RASTER3D_cache::eltSize, NULL, Rast3d_cache_elt_ptr(), and Rast3d_error().

◆ Rast3d_cache_load()

int Rast3d_cache_load ( RASTER3D_cache c,
int  name 
)

Definition at line 515 of file cache1.c.

References NULL, Rast3d_cache_elt_ptr(), and Rast3d_error().

◆ Rast3d_cache_lock()

int Rast3d_cache_lock ( RASTER3D_cache c,
int  name 
)

◆ Rast3d_cache_lock_all()

int Rast3d_cache_lock_all ( RASTER3D_cache c)

Definition at line 339 of file cache1.c.

References IS_UNLOCKED_ELT, RASTER3D_cache::nofElts, and Rast3d_cache_lock_intern().

◆ Rast3d_cache_lock_intern()

void Rast3d_cache_lock_intern ( RASTER3D_cache c,
int  index 
)

Definition at line 291 of file cache1.c.

References IS_LOCKED_ELT.

Referenced by Rast3d_cache_elt_ptr(), and Rast3d_cache_lock_all().

◆ Rast3d_cache_new()

void* Rast3d_cache_new ( int  nofElts,
int  sizeOfElts,
int  nofNames,
int(*)()  eltRemoveFun,
void *  eltRemoveFunData,
int(*)()  eltLoadFun,
void *  eltLoadFunData 
)

Definition at line 88 of file cache1.c.

Referenced by Rast3d_cache_new_read().

◆ Rast3d_cache_new_read()

void* Rast3d_cache_new_read ( int  nofElts,
int  sizeOfElts,
int  nofNames,
read_fn eltLoadFun,
void *  eltLoadFunData 
)

Definition at line 161 of file cache1.c.

References Rast3d_cache_new().

◆ Rast3d_cache_put_elt()

int Rast3d_cache_put_elt ( RASTER3D_cache c,
int  name,
const void *  src 
)

Definition at line 544 of file cache1.c.

◆ Rast3d_cache_remove_all()

int Rast3d_cache_remove_all ( RASTER3D_cache c)

◆ Rast3d_cache_remove_elt()

int Rast3d_cache_remove_elt ( RASTER3D_cache c,
int  name 
)

Definition at line 408 of file cache1.c.

Referenced by Rast3d__remove_tile(), and Rast3d_cache_remove_all().

◆ Rast3d_cache_reset()

void Rast3d_cache_reset ( RASTER3D_cache c)

Definition at line 34 of file cache1.c.

◆ Rast3d_cache_set_load_fun()

void Rast3d_cache_set_load_fun ( RASTER3D_cache c,
int(*)()  eltLoadFun,
void *  eltLoadFunData 
)

Definition at line 152 of file cache1.c.

References RASTER3D_cache::eltLoadFun, and RASTER3D_cache::eltLoadFunData.

◆ Rast3d_cache_set_min_unlock()

void Rast3d_cache_set_min_unlock ( RASTER3D_cache c,
int  nofMinUnLocked 
)

Definition at line 366 of file cache1.c.

References RASTER3D_cache::minUnlocked.

Referenced by Rast3d_min_unlocked().

◆ Rast3d_cache_set_remove_fun()

void Rast3d_cache_set_remove_fun ( RASTER3D_cache c,
int(*)()  eltRemoveFun,
void *  eltRemoveFunData 
)

Definition at line 142 of file cache1.c.

◆ Rast3d_cache_unlock()

int Rast3d_cache_unlock ( RASTER3D_cache c,
int  name 
)

◆ Rast3d_cache_unlock_all()

int Rast3d_cache_unlock_all ( RASTER3D_cache c)