Skip to content

Commit ab9dd68

Browse files
committed
[px_sched] fixed proper padding in ObjectPool
1 parent 0106601 commit ab9dd68

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

px_sched.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,11 @@ namespace px_sched {
211211
T element;
212212
#if PX_SCHED_CACHE_LINE_SIZE
213213
// Avoid false sharing between threads
214-
char padding[PX_SCHED_CACHE_LINE_SIZE];
214+
static const size_t PADDING_ADJUSTMENT =
215+
( PX_SCHED_CACHE_LINE_SIZE
216+
- ((sizeof(state)+sizeof(version)+sizeof(element))%PX_SCHED_CACHE_LINE_SIZE)
217+
) % PX_SCHED_CACHE_LINE_SIZE;
218+
char padding[PADDING_ADJUSTMENT];
215219
#endif
216220
};
217221
D *data_ = nullptr;
@@ -423,6 +427,11 @@ namespace px_sched {
423427
static void WorkerThreadMain(Scheduler *schd, Worker *);
424428
#endif
425429

430+
#ifdef PX_SCHED_CONFIG_SINGLE_THREAD
431+
ObjectPool<Task> tasks_;
432+
ObjectPool<Counter> counters_;
433+
#endif // PX_SCHED_CONFIG_SINGLE_THREAD
434+
426435
};
427436

428437
//-- Optional: Mutex template to encapsultae scheduler notification ----------

0 commit comments

Comments
 (0)