activemq-cpp-3.6.0
Main Page
Namespaces
Data Structures
Files
File List
Globals
Condition.h
Go to the documentation of this file.
1
/*
2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
18
#ifndef _DECAF_UTIL_CONCURRENT_LOCKS_CONDITION_H_
19
#define _DECAF_UTIL_CONCURRENT_LOCKS_CONDITION_H_
20
21
#include <
decaf/util/Config.h
>
22
23
#include <
decaf/util/Date.h
>
24
#include <
decaf/util/concurrent/TimeUnit.h
>
25
#include <
decaf/lang/exceptions/RuntimeException.h
>
26
#include <
decaf/lang/exceptions/InterruptedException.h
>
27
#include <
decaf/lang/exceptions/IllegalMonitorStateException.h
>
28
29
namespace
decaf {
30
namespace
util {
31
namespace
concurrent {
32
namespace
locks {
33
132
class
DECAF_API
Condition
{
133
public
:
134
135
virtual
~
Condition
();
136
185
virtual
void
await() = 0;
186
221
virtual
void
awaitUninterruptibly() = 0;
222
303
virtual
long
long
awaitNanos(
long
long
nanosTimeout) = 0;
304
327
virtual
bool
await(
long
long
time,
const
TimeUnit
& unit) = 0;
328
329
/*
330
* Causes the current thread to wait until it is signaled or interrupted, or the
331
* specified deadline elapses.
332
*
333
* The lock associated with this condition is atomically released and the current
334
* thread becomes disabled for thread scheduling purposes and lies dormant until one
335
* of five things happens:
336
*
337
* * Some other thread invokes the signal() method for this Condition and the
338
* current thread happens to be chosen as the thread to be awakened; or
339
* * Some other thread invokes the signalAll() method for this Condition; or
340
* * Some other thread interrupts the current thread, and interruption of thread
341
* suspension is supported; or
342
* * The specified deadline elapses; or
343
* * A "spurious wakeup" occurs.
344
*
345
* In all cases, before this method can return the current thread must re-acquire the
346
* lock associated with this condition. When the thread returns it is guaranteed to
347
* hold this lock.
348
*
349
* If the current thread:
350
*
351
* * has its interrupted status set on entry to this method; or
352
* * is interrupted while waiting and interruption of thread suspension is supported,
353
*
354
* then InterruptedException is thrown and the current thread's interrupted status is
355
* cleared. It is not specified, in the first case, whether or not the test for
356
* interruption occurs before the lock is released.
357
*
358
* The return value indicates whether the deadline has elapsed, which can be used as
359
* follows:
360
*
361
* bool aMethod( const Date& deadline ) {
362
* bool stillWaiting = true;
363
* while (!conditionBeingWaitedFor) {
364
* if (stillWaiting)
365
* stillWaiting = theCondition->awaitUntil(deadline);
366
* else
367
* return false;
368
* }
369
* // ...
370
* }
371
*
372
* Implementation Considerations
373
*
374
* The current thread is assumed to hold the lock associated with this Condition when
375
* this method is called. It is up to the implementation to determine if this is the
376
* case and if not, how to respond. Typically, an exception will be thrown (such as
377
* IllegalMonitorStateException) and the implementation must document that fact.
378
*
379
* An implementation can favor responding to an interrupt over normal method return
380
* in response to a signal, or over indicating the passing of the specified deadline.
381
* In either case the implementation must ensure that the signal is redirected to
382
* another waiting thread, if there is one.
383
*
384
* @param deadline - the absolute time to wait until
385
*
386
* @returns false if the deadline has elapsed upon return, else true
387
*
388
* @throws RuntimeException
389
* if an unexpected error occurs while trying to wait on the Condition.
390
*
391
* @throws InterruptedException
392
* if the current thread is interrupted (and interruption of thread suspension
393
* is supported)
394
*
395
* @throws IllegalMonitorStateException
396
* if the caller is not the lock owner.
397
*/
398
virtual
bool
awaitUntil(
const
Date
& deadline) = 0;
399
409
virtual
void
signal() = 0;
410
420
virtual
void
signalAll() = 0;
421
422
};
423
424
}}}}
425
426
#endif
/*_DECAF_UTIL_CONCURRENT_LOCKS_CONDITION_H_*/
src
main
decaf
util
concurrent
locks
Condition.h
Generated on Mon Mar 4 2013 10:25:46 for activemq-cpp-3.6.0 by
1.8.1.2