Editing On-demand accounting
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 6: | Line 6: | ||
== Current accounting model == | == Current accounting model == | ||
Basically allocation of any kind of resource looks like this: | Basically allocation of any kind of resource looks like this: | ||
− | < | + | <pre> |
struct some_resource *get_the_resource(int amount) | struct some_resource *get_the_resource(int amount) | ||
{ | { | ||
Line 14: | Line 14: | ||
return ret; | return ret; | ||
} | } | ||
− | </ | + | </pre> |
We change this behaviour to work like this: | We change this behaviour to work like this: | ||
− | < | + | <pre> |
struct some_resource *get_the_resource(int amount) | struct some_resource *get_the_resource(int amount) | ||
{ | { | ||
Line 31: | Line 31: | ||
return NULL; | return NULL; | ||
} | } | ||
− | </ | + | </pre> |
The <code>charge_beancounter()</code> call is responsible for checking whether the user is allowed to get the requested amount of the resource, i.e. if the resource consumption level is lower than the limit set. | The <code>charge_beancounter()</code> call is responsible for checking whether the user is allowed to get the requested amount of the resource, i.e. if the resource consumption level is lower than the limit set. | ||