MoonGen
 All Files Functions Variables Pages
barrier.lua
Go to the documentation of this file.
1 ---------------------------------
2 --- @file barrier.lua
3 --- @brief Barrier ...
4 --- @todo TODO docu
5 ---------------------------------
6 
7 local mod = {}
8 
9 local ffi = require "ffi"
10 
11 
12 ffi.cdef [[
13  struct barrier { };
14  struct barrier* make_barrier(size_t n);
15  void barrier_wait(struct barrier* barrier);
16  void barrier_reinit(struct barrier* barrier, size_t n);
17 ]]
18 
19 local C = ffi.C
20 
21 local barrier = {}
22 barrier.__index = barrier
23 
24 ---
25 --- @param n
26 function mod.new(n)
27  return C.make_barrier(n)
28 end
29 
30 ---
31 function barrier:wait()
32  C.barrier_wait(self)
33 end
34 
35 ---
36 --- only call if NO threads are waiting on this barrier
37 --- @param n
38 function barrier:reinit(n)
39  C.barrier_reinit(self, n)
40 end
41 
42 ffi.metatype("struct barrier", barrier)
43 
44 return mod
local ffi
low-level dpdk wrapper
Definition: dpdkc.lua:6
function barrier reinit(n)
only call if NO threads are waiting on this barrier
local mod
high-level dpdk wrapper
Definition: dpdk.lua:6
n
Create a new array of memory buffers (initialized to nil).
Definition: memory.lua:76