1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ******************************************************************************
5 * Copyright (C) 2014, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
8 * sharedbreakiterator.h
11 #ifndef __SHARED_BREAKITERATOR_H__
12 #define __SHARED_BREAKITERATOR_H__
14 #include "unicode/utypes.h"
15 #include "sharedobject.h"
17 #if !UCONFIG_NO_BREAK_ITERATION
23 // SharedBreakIterator encapsulates a shared BreakIterator. Because
24 // BreakIterator has mutable semantics, clients must ensure that all uses
25 // of a particular shared BreakIterator is protected by the same mutex
26 // ensuring that only one thread at a time gets access to that shared
27 // BreakIterator. Clients can accomplish this by creating a mutex for all
28 // uses of break iterator within a particular class. Then objects of that
29 // class may then freely share break iterators among themselves. However,
30 // these shared break iterators must never be exposed outside of that class.
31 class U_I18N_API SharedBreakIterator : public SharedObject {
33 SharedBreakIterator(BreakIterator *biToAdopt);
34 virtual ~SharedBreakIterator();
36 BreakIterator *get() const { return ptr; }
37 BreakIterator *operator->() const { return ptr; }
38 BreakIterator &operator*() const { return *ptr; }
41 SharedBreakIterator(const SharedBreakIterator &);
42 SharedBreakIterator &operator=(const SharedBreakIterator &);