git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5038 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2013-01-07 09:53:34 +00:00
parent 25002cf195
commit fe7aa77ae0
3 changed files with 16 additions and 10 deletions

View File

@ -107,8 +107,8 @@ namespace chibios_fatfs {
/*------------------------------------------------------------------------*
* chibios_fatfs::FatFSFilesPool *
*------------------------------------------------------------------------*/
FatFSFilesPool::FatFSFilesPool(void) : MemoryPoolBuffer<FatFSFileWrapper,
FATFS_MAX_FILES>() {
FatFSFilesPool::FatFSFilesPool(void) : ObjectsPool<FatFSFileWrapper,
FATFS_MAX_FILES>() {
}

View File

@ -92,8 +92,8 @@ namespace chibios_fatfs {
/**
* @brief Class of memory pool of @p FatFSFileWrapper objects.
*/
class FatFSFilesPool : public MemoryPoolBuffer<FatFSFileWrapper,
FATFS_MAX_FILES> {
class FatFSFilesPool : public ObjectsPool<FatFSFileWrapper,
FATFS_MAX_FILES> {
public:
FatFSFilesPool(void);
};

View File

@ -2128,23 +2128,29 @@ namespace chibios_rt {
};
/*------------------------------------------------------------------------*
* chibios_rt::MemoryPool *
* chibios_rt::ObjectsPool *
*------------------------------------------------------------------------*/
/**
* @brief Template class encapsulating a mailbox and its elements.
* @brief Template class encapsulating a memory pool and its elements.
*/
template<class T, size_t N>
class MemoryPoolBuffer : public MemoryPool {
class ObjectsPool : public MemoryPool {
private:
T pool_buf[N];
/* The buffer is declared as an array of pointers to void for two
reasons:
1) The objects must be properly aligned to hold a pointer as
first field.
2) There is no need to invoke constructors for object that are
into the pool.*/
void *pool_buf[(N * sizeof (T)) / sizeof (void *)];
public:
/**
* @brief MemoryPoolBuffer constructor.
* @brief ObjectsPool constructor.
*
* @init
*/
MemoryPoolBuffer(void) : MemoryPool(sizeof (T), NULL) {
ObjectsPool(void) : MemoryPool(sizeof (T), NULL) {
loadArray(pool_buf, N);
}