| | 91 | /** Enqueue a group of messages and wait for all of them (really only |
|---|
| | 92 | useful with a Dispatcher or some other delegating actor) */ |
|---|
| | 93 | void enqueueSync(Message[] msgs) |
|---|
| | 94 | { |
|---|
| | 95 | // make all our semaphores |
|---|
| | 96 | Semaphore[] sems; |
|---|
| | 97 | sems.length = msgs.length; |
|---|
| | 98 | foreach (i, m; msgs) { |
|---|
| | 99 | sems[i] = new Semaphore; |
|---|
| | 100 | } |
|---|
| | 101 | |
|---|
| | 102 | // enqueue all the messages |
|---|
| | 103 | foreach (i, m; msgs) { |
|---|
| | 104 | enqueue(new SyncMessage(sems[i], m)); |
|---|
| | 105 | } |
|---|
| | 106 | |
|---|
| | 107 | // then wait on all the semaphores |
|---|
| | 108 | foreach (s; sems) { |
|---|
| | 109 | s.wait(); |
|---|
| | 110 | } |
|---|
| | 111 | } |
|---|
| | 112 | |
|---|