Fawkes API
Fawkes Development Version
interruptible_barrier.h
1
2
/***************************************************************************
3
* interruptible_barrier.h - Interruptible Barrier
4
*
5
* Created: Sat Jan 31 12:27:54 2009
6
* Copyright 2006-2009 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version. A runtime exception applies to
14
* this software (see LICENSE.GPL_WRE file mentioned below for details).
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Library General Public License for more details.
20
*
21
* Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22
*/
23
24
#ifndef _CORE_THREADING_INTERRUPTIBLE_BARRIER_H_
25
#define _CORE_THREADING_INTERRUPTIBLE_BARRIER_H_
26
27
#include <core/threading/barrier.h>
28
#include <core/utils/refptr.h>
29
30
namespace
fawkes
{
31
32
class
InterruptibleBarrierData;
33
class
ThreadList;
34
35
class
InterruptibleBarrier :
public
Barrier
36
{
37
public
:
38
InterruptibleBarrier
(
unsigned
int
count
);
39
InterruptibleBarrier
(Mutex *mutex,
unsigned
int
count
);
40
virtual
~InterruptibleBarrier
();
41
42
bool
wait
(
unsigned
int
timeout_sec,
unsigned
int
timeout_nanosec);
43
virtual
inline
void
44
wait
()
45
{
46
wait
(0, 0);
47
}
48
49
void
interrupt
() throw();
50
void
reset
() throw();
51
52
RefPtr
<
ThreadList
>
passed_threads
();
53
54
bool
no_threads_in_wait
();
55
56
private:
57
InterruptibleBarrier
(const
InterruptibleBarrier
&b);
58
InterruptibleBarrier
(const
InterruptibleBarrier
*b);
59
InterruptibleBarrier
&operator=(const
InterruptibleBarrier
&b);
60
InterruptibleBarrier
&operator=(const
InterruptibleBarrier
*b);
61
62
private:
63
InterruptibleBarrierData *data_;
64
RefPtr
<
ThreadList
> passed_threads_;
65
66
bool
interrupted_;
67
bool
timeout_;
68
bool
wait_at_barrier_;
69
int
num_threads_in_wait_function_;
70
};
71
72
}
// end namespace fawkes
73
74
#endif
fawkes::RefPtr
RefPtr<> is a reference-counting shared smartpointer.
Definition:
refptr.h:57
fawkes::InterruptibleBarrier::~InterruptibleBarrier
virtual ~InterruptibleBarrier()
Destructor.
Definition:
interruptible_barrier.cpp:171
fawkes::InterruptibleBarrier::interrupt
void interrupt()
Interrupt the barrier.
Definition:
interruptible_barrier.cpp:195
fawkes::InterruptibleBarrier::passed_threads
RefPtr< ThreadList > passed_threads()
Get a list of threads that passed the barrier.
Definition:
interruptible_barrier.cpp:183
fawkes
fawkes::InterruptibleBarrier::no_threads_in_wait
bool no_threads_in_wait()
Checks if there are no more threads in the wait() function.
Definition:
interruptible_barrier.cpp:327
fawkes::InterruptibleBarrier::InterruptibleBarrier
InterruptibleBarrier(unsigned int count)
Constructor.
Definition:
interruptible_barrier.cpp:90
fawkes::Barrier::count
unsigned int count()
Get number of threads this barrier will wait for.
Definition:
barrier.cpp:182
fawkes::InterruptibleBarrier
Definition:
interruptible_barrier.h:41
fawkes::ThreadList
Definition:
thread_list.h:61
fawkes::InterruptibleBarrier::wait
virtual void wait()
Wait for other threads.
Definition:
interruptible_barrier.h:50
fawkes::InterruptibleBarrier::reset
void reset()
Clears the barrier.
Definition:
interruptible_barrier.cpp:211
src
libs
core
threading
interruptible_barrier.h
Generated by
1.8.17