My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* Copyright 2011 LMAX Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.lmax.disruptor;

import java.util.concurrent.TimeUnit;

/**
* Strategy employed for making {@link EventProcessor}s wait on a cursor {@link Sequence}.
*/
public interface WaitStrategy
{
/**
* Wait for the given sequence to be available
*
* @param sequence to be waited on.
* @param cursor on which to wait.
* @param dependents further back the chain that must advance first
* @param barrier the processor is waiting on.
* @return the sequence that is available which may be greater than the requested sequence.
* @throws AlertException if the status of the Disruptor has changed.
* @throws InterruptedException if the thread is interrupted.
*/
long waitFor(long sequence, Sequence cursor, Sequence[] dependents, SequenceBarrier barrier)
throws AlertException, InterruptedException;

/**
* Wait for the given sequence to be available with a timeout specified.
*
* @param sequence to be waited on.
* @param cursor on which to wait.
* @param dependents further back the chain that must advance first
* @param barrier the processor is waiting on.
* @param timeout value to abort after.
* @param sourceUnit of the timeout value.
* @return the sequence that is available which may be greater than the requested sequence.
* @throws AlertException if the status of the Disruptor has changed.
* @throws InterruptedException if the thread is interrupted.
*/
long waitFor(long sequence, Sequence cursor, Sequence[] dependents, SequenceBarrier barrier, long timeout, TimeUnit sourceUnit)
throws AlertException, InterruptedException;

/**
* Signal those {@link EventProcessor}s waiting that the cursor has advanced.
*/
void signalAllWhenBlocking();
}

Change log

r475 by mjpt777 on Nov 10, 2011   Diff
Naming of TimeUnit parameters to reflect
it is the source TimeUnit.
Go to: 
Project members, sign in to write a code review

Older revisions

r469 by mjpt777 on Nov 2, 2011   Diff
Opened up claim and wait strategies so
user defined ones can be applied.
r465 by mjpt777 on Nov 1, 2011   Diff
Use LockSupport.parkNanos in
SleepingWaitStrategy to reduce latency
by sleeping for must less than 1ms.
r464 by mjpt777 on Nov 1, 2011   Diff
Fully name claim and wait strategies.
All revisions of this file

File info

Size: 2400 bytes, 59 lines
Powered by Google Project Hosting