Helps with determining if resources can be fairly allocated given current conditions.
More...
Go to the source code of this file.
|
|
typedef struct qev_fair | qev_fair_t |
| | Don't even try modifying this.
|
| |
|
| qev_fair_t * | qev_fair_new (const gchar *name, const guint total, const gsize pressure, const gsize min) |
| | Create a new limited pool that needs allocating. More...
|
| |
| void | qev_fair_free (qev_fair_t *fair) |
| | Free the fairness pool. More...
|
| |
| gboolean | qev_fair_use (qev_fair_t *fair, const gsize in_use, const gsize wants) |
| | Determines if the given number of resources may be used. More...
|
| |
| gboolean | qev_fair_used (qev_fair_t *fair, const gsize in_use, const gsize added) |
| | Like qev_fair_use, except this one just tells the fair pool that the number of resources has already been allocated. More...
|
| |
| void | qev_fair_return (qev_fair_t *fair, const gsize giving) |
| | Return used resources to the pool. More...
|
| |
|
gsize | qev_fair_get_usage (qev_fair_t *fair) |
| | Get how much of the shared resource is currently in use.
|
| |
| void | qev_fair_set_total (qev_fair_t *fair, const gsize total) |
| | Set the total number of things the pool may allocate. More...
|
| |
| void | qev_fair_set_pressure (qev_fair_t *fair, const gsize pressure) |
| | Change the pressure of the pool. More...
|
| |
| void | qev_fair_set_min (qev_fair_t *fair, const gsize min) |
| | Change the min allocation for the pool. More...
|
| |
Helps with determining if resources can be fairly allocated given current conditions.
Typically, this is used for allocating limited resources to clients.
- Author
- Andrew Stone andre.nosp@m.w@cl.nosp@m.ovar..nosp@m.com
- Copyright
- 2012-2014 Clear Channel Inc.
Free the fairness pool.
- Parameters
-
| qev_fair_t* qev_fair_new |
( |
const gchar * |
name, |
|
|
const guint |
total, |
|
|
const gsize |
pressure, |
|
|
const gsize |
min |
|
) |
| |
Create a new limited pool that needs allocating.
- Note
- Because pools use stats, they must be setup completely before the server is run.
- Parameters
-
| name | The name of this pool. A stat will be created with this name that reports the status of this pool. |
| total | The total number of resources that this pool may distribute |
| pressure | At what percent of total pressure should be applied to bring resource usage back down |
| min | The smallest amount of resources that a single client has access to, regardless of memory pressure. If the number of allocated resources is greater than total, then this will be ignored. |
- Returns
- The fairness allocation pool.
| void qev_fair_return |
( |
qev_fair_t * |
fair, |
|
|
const gsize |
giving |
|
) |
| |
Return used resources to the pool.
- Parameters
-
| fair | The fair pool to return resources to |
| giving | The number of resources that are being given up |
| void qev_fair_set_min |
( |
qev_fair_t * |
fair, |
|
|
const gsize |
min |
|
) |
| |
Change the min allocation for the pool.
- Parameters
-
| fair | The pool to update |
| min | The new min value (will be constrained to be less than total) |
| void qev_fair_set_pressure |
( |
qev_fair_t * |
fair, |
|
|
const gsize |
pressure |
|
) |
| |
Change the pressure of the pool.
- Parameters
-
| fair | The pool to update |
| pressure | The new pressure for the pool (0-100) |
| void qev_fair_set_total |
( |
qev_fair_t * |
fair, |
|
|
const gsize |
total |
|
) |
| |
Set the total number of things the pool may allocate.
- Parameters
-
| fair | The pool to update |
| total | The new total resource count for the pool |
| gboolean qev_fair_use |
( |
qev_fair_t * |
fair, |
|
|
const gsize |
in_use, |
|
|
const gsize |
wants |
|
) |
| |
Determines if the given number of resources may be used.
- Note
- This only gives a fuzzy yes/no. It's possible for this to give out more than the number of available resources as no locks are used. In reality, it will only really give out a slightly-higher number of resources.
- Parameters
-
| fair | The fair pool to allocate from |
| in_use | How many resources this user has already used from the pool |
| wants | How many additional resources the user wants. |
- Returns
- If the user may, in fact, allocate the request resources.
| gboolean qev_fair_used |
( |
qev_fair_t * |
fair, |
|
|
const gsize |
in_use, |
|
|
const gsize |
added |
|
) |
| |
Like qev_fair_use, except this one just tells the fair pool that the number of resources has already been allocated.
Like qev_fair_use, this will return if the number of resources now in use is too many.
- Parameters
-
| fair | The fair pool to allocate from |
| in_use | How many resources this user has already used from the pool |
| added | How many additional resources the user took |
- Returns
- If the user is now using too many of the resource.