Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
AsyncNotifiableBlock.cxx
Go to the documentation of this file.
1
38#ifndef _DEFAULT_SOURCE
39#define _DEFAULT_SOURCE
40#endif
41
43
44#include "os/sleep.h"
45
47{
48 // Recollects all notifiable instances, including waiting as long as needed
49 // if there are some that have not finished yet.
50 for (unsigned i = 0; i < count_; ++i)
51 {
52 while (true)
53 {
54 QMember *m = next().item;
55 if (!m)
56 {
58 "shutdown async notifiable block: waiting for returns");
59 microsleep(100);
60 }
61 else
62 {
63 HASSERT(initialize(m)->abort_if_almost_done());
64 break;
65 }
66 }
67 }
68}
BarrierNotifiable * initialize(QMember *entry)
Turns an allocated entry from the QAsync into a usable BarrierNotifiable.
unsigned count_
How many barriers do we have.
Result next()
Get an item from the front of the queue.
Definition Queue.hxx:343
Essentially a "next" pointer container.
Definition QMember.hxx:42
#define LOG(level, message...)
Conditionally write a message to the logging output.
Definition logging.h:99
static const int VERBOSE
Loglevel that is usually not printed, reporting debugging information.
Definition logging.h:59
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
Definition macros.h:138
static void microsleep(uint32_t microseconds)
Sleep a given number of microseconds.
QMember * item
item pulled from queue
Definition Queue.hxx:84