2 ******************************************************************************
3 * Copyright (C) 2014, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ******************************************************************************
6 * sharedbreakiterator.h
9 #ifndef __SHARED_BREAKITERATOR_H__
10 #define __SHARED_BREAKITERATOR_H__
12 #include "unicode/utypes.h"
13 #include "sharedobject.h"
15 #if !UCONFIG_NO_BREAK_ITERATION
21 // SharedBreakIterator encapsulates a shared BreakIterator. Because
22 // BreakIterator has mutable semantics, clients must ensure that all uses
23 // of a particular shared BreakIterator is protected by the same mutex
24 // ensuring that only one thread at a time gets access to that shared
25 // BreakIterator. Clients can accomplish this by creating a mutex for all
26 // uses of break iterator within a particular class. Then objects of that
27 // class may then freely share break iterators among themselves. However,
28 // these shared break iterators must never be exposed outside of that class.
29 class U_I18N_API SharedBreakIterator
: public SharedObject
{
31 SharedBreakIterator(BreakIterator
*biToAdopt
);
32 virtual ~SharedBreakIterator();
34 BreakIterator
*get() const { return ptr
; }
35 BreakIterator
*operator->() const { return ptr
; }
36 BreakIterator
&operator*() const { return *ptr
; }
39 SharedBreakIterator(const SharedBreakIterator
&);
40 SharedBreakIterator
&operator=(const SharedBreakIterator
&);