Class ManyToOneConcurrentLinkedQueue<E>

Type Parameters:
E - element type in the queue.
All Implemented Interfaces:
Iterable<E>, Collection<E>, Queue<E>

public class ManyToOneConcurrentLinkedQueue<E> extends ManyToOneConcurrentLinkedQueueHead<E> implements Queue<E>
Concurrent linked Queue that can be used from many producers and a single consumer.

This is a Java port of Dmitry Vyukov's MPSC linked queue.

Note: This queue breaks the contract for peek and poll in that it can return null when the queue has no item available but size could be greater than zero if an offer is in progress. This is due to the offer being a multiple step process which can start and be interrupted before completion, the thread will later be resumed and the offer process completes. Other methods, such as peek and poll, could spin internally waiting on the offer to complete to provide sequentially consistency across methods but this can have a detrimental effect in a resource starved system. This internal spinning eats up a CPU core and prevents other threads making progress resulting in latency spikes. To avoid this a more relaxed approach is taken in that an in-progress offer is not waited on to complete.

If you wish to check for empty then call isEmpty() rather than size() checking for zero.

  • Field Details

    • p128

      byte p128
    • p129

      byte p129
    • p130

      byte p130
    • p131

      byte p131
    • p132

      byte p132
    • p133

      byte p133
    • p134

      byte p134
    • p135

      byte p135
    • p136

      byte p136
    • p137

      byte p137
    • p138

      byte p138
    • p139

      byte p139
    • p140

      byte p140
    • p142

      byte p142
    • p143

      byte p143
    • p144

      byte p144
    • p145

      byte p145
    • p146

      byte p146
    • p147

      byte p147
    • p148

      byte p148
    • p149

      byte p149
    • p150

      byte p150
    • p151

      byte p151
    • p152

      byte p152
    • p153

      byte p153
    • p154

      byte p154
    • p155

      byte p155
    • p156

      byte p156
    • p157

      byte p157
    • p158

      byte p158
    • p159

      byte p159
    • p160

      byte p160
    • p161

      byte p161
    • p162

      byte p162
    • p163

      byte p163
    • p164

      byte p164
    • p165

      byte p165
    • p166

      byte p166
    • p167

      byte p167
    • p168

      byte p168
    • p169

      byte p169
    • p170

      byte p170
    • p171

      byte p171
    • p172

      byte p172
    • p173

      byte p173
    • p174

      byte p174
    • p175

      byte p175
    • p176

      byte p176
    • p177

      byte p177
    • p178

      byte p178
    • p179

      byte p179
    • p180

      byte p180
    • p181

      byte p181
    • p182

      byte p182
    • p183

      byte p183
    • p184

      byte p184
    • p185

      byte p185
    • p186

      byte p186
    • p187

      byte p187
    • p189

      byte p189
    • p190

      byte p190
    • p191

      byte p191
    • p192

      byte p192
    • p193

      byte p193
    • empty

  • Constructor Details

    • ManyToOneConcurrentLinkedQueue

      public ManyToOneConcurrentLinkedQueue()
      Constructs an empty queue.
  • Method Details