Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2011-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include "macos_appnap.h"7#include <AvailabilityMacros.h>8#include <Foundation/NSProcessInfo.h>9#include <Foundation/Foundation.h>11class CAppNapInhibitor::CAppNapImpl12{13public:14~CAppNapImpl()15{16if(activityId)17enableAppNap();18}20void disableAppNap()21{22if (!activityId)23{24@autoreleasepool {25const NSActivityOptions activityOptions =26NSActivityUserInitiatedAllowingIdleSystemSleep &27~(NSActivitySuddenTerminationDisabled |28NSActivityAutomaticTerminationDisabled);30id processInfo = [NSProcessInfo processInfo];31if ([processInfo respondsToSelector:@selector(beginActivityWithOptions:reason:)])32{33activityId = [processInfo beginActivityWithOptions: activityOptions reason:@"Temporarily disable App Nap for bitcoin-qt."];34[activityId retain];35}36}37}38}40void enableAppNap()41{42if(activityId)43{44@autoreleasepool {45id processInfo = [NSProcessInfo processInfo];46if ([processInfo respondsToSelector:@selector(endActivity:)])47[processInfo endActivity:activityId];49[activityId release];50activityId = nil;51}52}53}55private:56NSObject* activityId;57};59CAppNapInhibitor::CAppNapInhibitor() : impl(new CAppNapImpl()) {}61CAppNapInhibitor::~CAppNapInhibitor() = default;63void CAppNapInhibitor::disableAppNap()64{65impl->disableAppNap();66}68void CAppNapInhibitor::enableAppNap()69{70impl->enableAppNap();71}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.