Skip to content

Commit 9cef738

Browse files
committed
constexpr + noexcept in Attachment
1 parent 28835be commit 9cef738

File tree

1 file changed

+71
-70
lines changed

1 file changed

+71
-70
lines changed

src/jrd/Attachment.h

Lines changed: 71 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -149,34 +149,34 @@ struct DdlTriggerContext
149149

150150
// Attachment flags
151151

152-
const ULONG ATT_no_cleanup = 0x00001L; // Don't expunge, purge, or garbage collect
153-
const ULONG ATT_shutdown = 0x00002L; // attachment has been shutdown
154-
const ULONG ATT_shutdown_manager = 0x00004L; // attachment requesting shutdown
155-
const ULONG ATT_exclusive = 0x00008L; // attachment wants exclusive database access
156-
const ULONG ATT_attach_pending = 0x00010L; // Indicate attachment is only pending
157-
const ULONG ATT_exclusive_pending = 0x00020L; // Indicate exclusive attachment pending
158-
const ULONG ATT_notify_gc = 0x00040L; // Notify garbage collector to expunge, purge ..
159-
const ULONG ATT_garbage_collector = 0x00080L; // I'm a garbage collector
160-
const ULONG ATT_cancel_raise = 0x00100L; // Cancel currently running operation
161-
const ULONG ATT_cancel_disable = 0x00200L; // Disable cancel operations
162-
const ULONG ATT_no_db_triggers = 0x00400L; // Don't execute database triggers
163-
const ULONG ATT_manual_lock = 0x00800L; // Was locked manually
164-
const ULONG ATT_async_manual_lock = 0x01000L; // Async mutex was locked manually
165-
const ULONG ATT_overwrite_check = 0x02000L; // Attachment checks is it possible to overwrite DB
166-
const ULONG ATT_system = 0x04000L; // Special system attachment
167-
const ULONG ATT_creator = 0x08000L; // This attachment created the DB
168-
const ULONG ATT_monitor_disabled = 0x10000L; // Monitoring lock is downgraded
169-
const ULONG ATT_security_db = 0x20000L; // Attachment used for security purposes
170-
const ULONG ATT_mapping = 0x40000L; // Attachment used for mapping auth block
171-
const ULONG ATT_from_thread = 0x80000L; // Attachment from internal special thread (sweep, crypt)
172-
const ULONG ATT_monitor_init = 0x100000L; // Attachment is registered in monitoring
173-
const ULONG ATT_repl_reset = 0x200000L; // Replication set has been reset
174-
const ULONG ATT_replicating = 0x400000L; // Replication is active
175-
const ULONG ATT_resetting = 0x800000L; // Session reset is in progress
176-
const ULONG ATT_worker = 0x1000000L; // Worker attachment, managed by the engine
177-
const ULONG ATT_gbak_restore_has_schema = 0x2000000L;
178-
179-
const ULONG ATT_NO_CLEANUP = (ATT_no_cleanup | ATT_notify_gc);
152+
inline constexpr ULONG ATT_no_cleanup = 0x00001L; // Don't expunge, purge, or garbage collect
153+
inline constexpr ULONG ATT_shutdown = 0x00002L; // attachment has been shutdown
154+
inline constexpr ULONG ATT_shutdown_manager = 0x00004L; // attachment requesting shutdown
155+
inline constexpr ULONG ATT_exclusive = 0x00008L; // attachment wants exclusive database access
156+
inline constexpr ULONG ATT_attach_pending = 0x00010L; // Indicate attachment is only pending
157+
inline constexpr ULONG ATT_exclusive_pending = 0x00020L; // Indicate exclusive attachment pending
158+
inline constexpr ULONG ATT_notify_gc = 0x00040L; // Notify garbage collector to expunge, purge ..
159+
inline constexpr ULONG ATT_garbage_collector = 0x00080L; // I'm a garbage collector
160+
inline constexpr ULONG ATT_cancel_raise = 0x00100L; // Cancel currently running operation
161+
inline constexpr ULONG ATT_cancel_disable = 0x00200L; // Disable cancel operations
162+
inline constexpr ULONG ATT_no_db_triggers = 0x00400L; // Don't execute database triggers
163+
inline constexpr ULONG ATT_manual_lock = 0x00800L; // Was locked manually
164+
inline constexpr ULONG ATT_async_manual_lock = 0x01000L; // Async mutex was locked manually
165+
inline constexpr ULONG ATT_overwrite_check = 0x02000L; // Attachment checks is it possible to overwrite DB
166+
inline constexpr ULONG ATT_system = 0x04000L; // Special system attachment
167+
inline constexpr ULONG ATT_creator = 0x08000L; // This attachment created the DB
168+
inline constexpr ULONG ATT_monitor_disabled = 0x10000L; // Monitoring lock is downgraded
169+
inline constexpr ULONG ATT_security_db = 0x20000L; // Attachment used for security purposes
170+
inline constexpr ULONG ATT_mapping = 0x40000L; // Attachment used for mapping auth block
171+
inline constexpr ULONG ATT_from_thread = 0x80000L; // Attachment from internal special thread (sweep, crypt)
172+
inline constexpr ULONG ATT_monitor_init = 0x100000L; // Attachment is registered in monitoring
173+
inline constexpr ULONG ATT_repl_reset = 0x200000L; // Replication set has been reset
174+
inline constexpr ULONG ATT_replicating = 0x400000L; // Replication is active
175+
inline constexpr ULONG ATT_resetting = 0x800000L; // Session reset is in progress
176+
inline constexpr ULONG ATT_worker = 0x1000000L; // Worker attachment, managed by the engine
177+
inline constexpr ULONG ATT_gbak_restore_has_schema = 0x2000000L;
178+
179+
inline constexpr ULONG ATT_NO_CLEANUP = (ATT_no_cleanup | ATT_notify_gc);
180180

181181
class Attachment;
182182
class DatabaseOptions;
@@ -215,13 +215,13 @@ class StableAttachmentPart : public Firebird::RefCounted, public Firebird::Globa
215215
class Sync
216216
{
217217
public:
218-
Sync()
218+
Sync() noexcept
219219
: waiters(0), threadId(0), totalLocksCounter(0), currentLocksCounter(0)
220220
{ }
221221

222222
void enter(const char* aReason)
223223
{
224-
ThreadId curTid = getThreadId();
224+
const ThreadId curTid = getThreadId();
225225

226226
if (threadId == curTid)
227227
{
@@ -245,7 +245,7 @@ class StableAttachmentPart : public Firebird::RefCounted, public Firebird::Globa
245245

246246
bool tryEnter(const char* aReason)
247247
{
248-
ThreadId curTid = getThreadId();
248+
const ThreadId curTid = getThreadId();
249249

250250
if (threadId == curTid)
251251
{
@@ -274,12 +274,12 @@ class StableAttachmentPart : public Firebird::RefCounted, public Firebird::Globa
274274
}
275275
}
276276

277-
bool hasContention() const
277+
bool hasContention() const noexcept
278278
{
279279
return (waiters.load(std::memory_order_relaxed) > 0);
280280
}
281281

282-
FB_UINT64 getLockCounter() const
282+
FB_UINT64 getLockCounter() const noexcept
283283
{
284284
return totalLocksCounter;
285285
}
@@ -299,8 +299,8 @@ class StableAttachmentPart : public Firebird::RefCounted, public Firebird::Globa
299299

300300
private:
301301
// copying is prohibited
302-
Sync(const Sync&);
303-
Sync& operator=(const Sync&);
302+
Sync(const Sync&) = delete;
303+
Sync& operator=(const Sync&) = delete;
304304

305305
Firebird::Mutex syncMutex;
306306
std::atomic<int> waiters;
@@ -318,7 +318,7 @@ class StableAttachmentPart : public Firebird::RefCounted, public Firebird::Globa
318318
return att;
319319
}
320320

321-
JAttachment* getInterface()
321+
JAttachment* getInterface() noexcept
322322
{
323323
return jAtt;
324324
}
@@ -341,7 +341,7 @@ class StableAttachmentPart : public Firebird::RefCounted, public Firebird::Globa
341341
return useAsync ? &async : &mainSync;
342342
}
343343

344-
Firebird::Mutex* getBlockingMutex()
344+
Firebird::Mutex* getBlockingMutex() noexcept
345345
{
346346
return &blockingMutex;
347347
}
@@ -367,13 +367,13 @@ class StableAttachmentPart : public Firebird::RefCounted, public Firebird::Globa
367367
void manualUnlock(ULONG& flags);
368368
void manualAsyncUnlock(ULONG& flags);
369369

370-
void setShutError(ISC_STATUS code)
370+
void setShutError(ISC_STATUS code) noexcept
371371
{
372372
if (!shutError)
373373
shutError = code;
374374
}
375375

376-
ISC_STATUS getShutError() const
376+
ISC_STATUS getShutError() const noexcept
377377
{
378378
return shutError;
379379
}
@@ -430,8 +430,8 @@ class Attachment : public pool_alloc<type_att>
430430

431431
private:
432432
// copying is prohibited
433-
SyncGuard(const SyncGuard&);
434-
SyncGuard& operator=(const SyncGuard&);
433+
SyncGuard(const SyncGuard&) = delete;
434+
SyncGuard& operator=(const SyncGuard&) = delete;
435435

436436
void init(const char* f, bool optional);
437437

@@ -502,12 +502,12 @@ class Attachment : public pool_alloc<type_att>
502502
void setInitialOptions(thread_db* tdbb, const DatabaseOptions& options);
503503
void resetAttachment(Attachment* attachment) const;
504504

505-
CoercionArray *getBindings()
505+
CoercionArray *getBindings() noexcept
506506
{
507507
return &bindings;
508508
}
509509

510-
const CoercionArray *getBindings() const
510+
const CoercionArray *getBindings() const noexcept
511511
{
512512
return &bindings;
513513
}
@@ -523,12 +523,12 @@ class Attachment : public pool_alloc<type_att>
523523
class DebugOptions
524524
{
525525
public:
526-
bool getDsqlKeepBlr() const
526+
bool getDsqlKeepBlr() const noexcept
527527
{
528528
return dsqlKeepBlr;
529529
}
530530

531-
void setDsqlKeepBlr(bool value)
531+
void setDsqlKeepBlr(bool value) noexcept
532532
{
533533
dsqlKeepBlr = value;
534534
}
@@ -540,7 +540,7 @@ class Attachment : public pool_alloc<type_att>
540540
class UseCountHolder
541541
{
542542
public:
543-
explicit UseCountHolder(Attachment* a)
543+
explicit UseCountHolder(Attachment* a) noexcept
544544
: att(a)
545545
{
546546
if (att)
@@ -711,22 +711,22 @@ class Attachment : public pool_alloc<type_att>
711711
/// former Database members - end
712712

713713
bool locksmith(thread_db* tdbb, SystemPrivilege sp) const;
714-
jrd_tra* getSysTransaction();
715-
void setSysTransaction(jrd_tra* trans); // used only by TRA_init
714+
jrd_tra* getSysTransaction() noexcept;
715+
void setSysTransaction(jrd_tra* trans) noexcept; // used only by TRA_init
716716

717-
bool isSystem() const
717+
inline bool isSystem() const noexcept
718718
{
719719
return (att_flags & ATT_system);
720720
}
721721

722-
bool isWorker() const
722+
inline bool isWorker() const noexcept
723723
{
724724
return (att_flags & ATT_worker);
725725
}
726726

727-
bool isGbak() const;
728-
bool isRWGbak() const;
729-
bool isUtility() const; // gbak, gfix and gstat.
727+
bool isGbak() const noexcept;
728+
bool isRWGbak() const noexcept;
729+
bool isUtility() const noexcept; // gbak, gfix and gstat.
730730

731731
PreparedStatement* prepareStatement(thread_db* tdbb, jrd_tra* transaction,
732732
const Firebird::string& text, Firebird::MemoryPool* pool = NULL);
@@ -772,24 +772,24 @@ class Attachment : public pool_alloc<type_att>
772772

773773
JAttachment* getInterface() noexcept;
774774

775-
unsigned int getIdleTimeout() const
775+
unsigned int getIdleTimeout() const noexcept
776776
{
777777
return att_idle_timeout;
778778
}
779779

780-
void setIdleTimeout(unsigned int timeOut)
780+
void setIdleTimeout(unsigned int timeOut) noexcept
781781
{
782782
att_idle_timeout = timeOut;
783783
}
784784

785785
unsigned int getActualIdleTimeout() const;
786786

787-
unsigned int getStatementTimeout() const
787+
unsigned int getStatementTimeout() const noexcept
788788
{
789789
return att_stmt_timeout;
790790
}
791791

792-
void setStatementTimeout(unsigned int timeOut)
792+
void setStatementTimeout(unsigned int timeOut) noexcept
793793
{
794794
att_stmt_timeout = timeOut;
795795
}
@@ -830,7 +830,7 @@ class Attachment : public pool_alloc<type_att>
830830
return att_user ? att_user->getSqlRole() : emptyName;
831831
}
832832

833-
const UserId* getEffectiveUserId() const
833+
const UserId* getEffectiveUserId() const noexcept
834834
{
835835
if (att_ss_user)
836836
return att_ss_user;
@@ -844,12 +844,13 @@ class Attachment : public pool_alloc<type_att>
844844
}
845845

846846
void setInitialOptions(thread_db* tdbb, DatabaseOptions& options, bool newDb);
847-
const CoercionArray* getInitialBindings() const
847+
848+
const CoercionArray* getInitialBindings() const noexcept
848849
{
849850
return att_initial_options.getBindings();
850851
}
851852

852-
DebugOptions& getDebugOptions()
853+
DebugOptions& getDebugOptions() noexcept
853854
{
854855
return att_debug_options;
855856
}
@@ -899,32 +900,32 @@ inline bool Attachment::locksmith(thread_db* tdbb, SystemPrivilege sp) const
899900
return (user && user->locksmith(tdbb, sp));
900901
}
901902

902-
inline jrd_tra* Attachment::getSysTransaction()
903+
inline jrd_tra* Attachment::getSysTransaction() noexcept
903904
{
904905
return att_sys_transaction;
905906
}
906907

907-
inline void Attachment::setSysTransaction(jrd_tra* trans)
908+
inline void Attachment::setSysTransaction(jrd_tra* trans) noexcept
908909
{
909910
att_sys_transaction = trans;
910911
}
911912

912913
// Connection is from GBAK
913-
inline bool Attachment::isGbak() const
914+
inline bool Attachment::isGbak() const noexcept
914915
{
915916
return (att_utility == UTIL_GBAK);
916917
}
917918

918919
// Gbak changes objects when it's restoring (creating) a db.
919920
// Other attempts are fake. Gbak reconnects to change R/O status and other db-wide settings,
920921
// but it doesn't modify generators or tables that seconds time.
921-
inline bool Attachment::isRWGbak() const
922+
inline bool Attachment::isRWGbak() const noexcept
922923
{
923924
return (isGbak() && (att_flags & ATT_creator));
924925
}
925926

926927
// Any of the three original utilities: gbak, gfix or gstat.
927-
inline bool Attachment::isUtility() const
928+
inline bool Attachment::isUtility() const noexcept
928929
{
929930
return (att_utility != UTIL_NONE);
930931
}
@@ -939,19 +940,19 @@ class AttachmentsRefHolder
939940
class Iterator
940941
{
941942
public:
942-
explicit Iterator(AttachmentsRefHolder& list)
943+
explicit Iterator(AttachmentsRefHolder& list) noexcept
943944
: m_list(list), m_index(0)
944945
{}
945946

946-
StableAttachmentPart* operator*()
947+
StableAttachmentPart* operator*() noexcept
947948
{
948949
if (m_index < m_list.m_attachments.getCount())
949950
return m_list.m_attachments[m_index];
950951

951952
return NULL;
952953
}
953954

954-
void operator++()
955+
void operator++() noexcept
955956
{
956957
m_index++;
957958
}
@@ -967,8 +968,8 @@ class AttachmentsRefHolder
967968

968969
private:
969970
// copying is prohibited
970-
Iterator(const Iterator&);
971-
Iterator& operator=(const Iterator&);
971+
Iterator(const Iterator&) = delete;
972+
Iterator& operator=(const Iterator&) = delete;
972973

973974
AttachmentsRefHolder& m_list;
974975
FB_SIZE_T m_index;

0 commit comments

Comments
 (0)