![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
timeslice.cpp
- Committer:
- klauss
- Date:
- 2015-04-30
- Revision:
- 119:ee6a53069455
- Parent:
- 0:4d17cd9c8f9d
- Child:
- 121:ee02790d00b7
File content as of revision 119:ee6a53069455:
#include "timeslice.h" Timeslice::Timeslice(){ for( register int i = 0; i < __MAX_TIMESLICES__; i++ ) timeslice[ i ] = 0; } Timeslice::~Timeslice(){ // do something here } uint8_t Timeslice::get_timeslice(){ for( register uint8_t i = 0; i < __MAX_TIMESLICES__; i++ ) if( timeslice[ i ] == 0 ){ timeslice[ i ] = 1; return( i + 1 ); } return( 0 ); } void Timeslice::return_timeslice( uint8_t ts ){ if( ts <= __MAX_TIMESLICES__ && ts > 0 ) timeslice[ ts - 1 ] = 0; } void Timeslice::reset(){ for( register uint8_t i = 0; i < __MAX_TIMESLICES__; i++ ) timeslice[ i ] = 0; } uint8_t Timeslice::remain_timeslices( void ){ uint8_t sum = 0; for( register uint8_t i = 0; i < __MAX_TIMESLICES__; i++ ){ if( timeslice[ i ] == 0 ) sum++; } return( sum ); }