A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://yazgoo.github.io/fuse_kafka/html/time__queue_8c.html below:

fuse_kafka: src/time_queue.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include "time_queue.h"

Go to the source code of this file.

Functions unsigned long  time_queue_hash (unsigned char *str)   Internal: generates a djb2 hash.
time_queue *  time_queue_new (unsigned int size, unsigned int quota)   Public: instantiates a new time queue, free it with time_queue_delete.
unsigned long  time_queue_time ()   Internal: get the time.
void  time_queue_set (time_queue *queue, char *key)   Public: set a time queue key to current time.
unsigned long *  time_queue_get (time_queue *queue, char *key)   Public: get last stored time pointer for given key.
int  time_queue_overflows (time_queue *queue, char *key, unsigned int size)   Internal: checks if the given key overflows the quota.
void  time_queue_delete (time_queue *queue)   Public: deletes the time queue structure and allocated content.
Detailed Description

A time queue is a datastructure which allows to store time for a finite number of keys. It allows to check if, for a given key, a limit per unit of time is reached or not.

Definition in file time_queue.c.

Function Documentation

Public: deletes the time queue structure and allocated content.

Parameters:
queue the queue to delete

Definition at line 149 of file time_queue.c.

Public: get last stored time pointer for given key.

Parameters:
queue the time queue to modify key the key to get the value from

Examples

time_queue_get(queue, "/unset/key") => NULL time_queue_get(queue, "/existing/key") => pointer to: 1412074060579654

Returns:
a pointer to the time value registered, NULL if there is none

Definition at line 110 of file time_queue.c.

Internal: generates a djb2 hash.

Parameters:

Examples

time_queue_hash('hello world') => 13876786532495509697

Returns:
a hash for the string

Definition at line 21 of file time_queue.c.

Public: instantiates a new time queue, free it with time_queue_delete.

Parameters:
size the maximum number of items saved in the queue quota the maximum size allowed per second per hash entry

Examples

time_queue_new(10, 42) => time_queue*

Returns:
a newly allocated pointer to a time queue of the specified size with the specified quota initialized to zero for values, and hashes

Definition at line 42 of file time_queue.c.

Internal: checks if the given key overflows the quota.

Parameters:
queue the time queue to get data from key the key to check size the size to compare with the quota

Examples

time_queue* queue = time_queue_new(10, 42); time_queue_set(queue, "/var/log/lol"); sleep(1); time_queue_overflows(queue, "/var/log/lol", 880); => 1

Returns:
0 if the key does not overflow the quota or no value exists for this key, 1 overwise

Definition at line 137 of file time_queue.c.

Public: set a time queue key to current time.

Parameters:
queue the time queue to modify key the key to set

Examples

time_queue_set(queue, "/var/log/blah.log")

Definition at line 75 of file time_queue.c.

Internal: get the time.

Returns:
current time in microseconds

Definition at line 60 of file time_queue.c.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4