Skip to content

Commit

Permalink
minor fixes for Abhishek's patch
Browse files Browse the repository at this point in the history
- fixed include order (local before system)
- fixed unused variable
- made member pointer const so reader knows it always gets initialized
- nullptr instead of NULL as nagged by clang-tidy
  • Loading branch information
iamsergio committed Jan 15, 2025
1 parent 3fcc426 commit e9447a0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <KDFoundation/platform/abstract_platform_event_loop.h>
#include <KDFoundation/kdfoundation_global.h>

#include <unordered_map>

namespace KDFoundation {
Expand Down
3 changes: 3 additions & 0 deletions src/KDFoundation/platform/macos/macos_platform_event_loop.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@

#include "macos_platform_event_loop.h"
#include "macos_platform_timer.h"

#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>

#include <limits>
#include <memory>

Expand Down Expand Up @@ -79,6 +81,7 @@
// TODO
return false;
}

std::unique_ptr<AbstractPlatformTimer> MacOSPlatformEventLoop::createPlatformTimerImpl(Timer *timer)
{
return std::make_unique<MacOSPlatformTimer>(timer);
Expand Down
8 changes: 4 additions & 4 deletions src/KDFoundation/platform/macos/macos_platform_timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

#pragma once

#include <KDFoundation/platform/abstract_platform_timer.h>
#include <KDFoundation/file_descriptor_notifier.h>

#include <CoreFoundation/CoreFoundation.h>

#include <chrono>

#include <KDFoundation/platform/abstract_platform_timer.h>
#include <KDFoundation/file_descriptor_notifier.h>

namespace KDFoundation {

class Timer;
Expand All @@ -32,7 +32,7 @@ class KDFOUNDATION_API MacOSPlatformTimer : public AbstractPlatformTimer
void arm(std::chrono::microseconds us);
void disarm();
static void timerFired(CFRunLoopTimerRef timer, void *info);
Timer *m_handler;
Timer *const m_handler;
CFRunLoopTimerRef cfTimer;
};

Expand Down
12 changes: 7 additions & 5 deletions src/KDFoundation/platform/macos/macos_platform_timer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@

#include "macos_platform_timer.h"
#include "macos_platform_event_loop.h"
#include "KDFoundation/core_application.h"
#include "KDFoundation/timer.h"
#include "KDFoundation/platform/macos/macos_platform_event_loop.h"

#include <Foundation/Foundation.h>

#include <algorithm>
#include <cassert>
#include <chrono>
#include <cstddef>
#include <type_traits>
#include <unistd.h>
#include "KDFoundation/core_application.h"
#include "KDFoundation/timer.h"
#include "KDFoundation/platform/macos/macos_platform_event_loop.h"

using namespace KDFoundation;

Expand Down Expand Up @@ -51,7 +53,7 @@
disarm();
}

void MacOSPlatformTimer::timerFired(CFRunLoopTimerRef timer, void *info)
void MacOSPlatformTimer::timerFired(CFRunLoopTimerRef timer, void *)
{
MacOSPlatformEventLoop *ev = eventLoop();
void *key = timer;
Expand All @@ -67,7 +69,7 @@
}

CFTimeInterval interval = std::chrono::duration_cast<std::chrono::duration<double>>(us).count();
CFRunLoopTimerContext timerContext = { 0, NULL, NULL, NULL, NULL };
CFRunLoopTimerContext timerContext = { 0, nullptr, nullptr, nullptr, nullptr };
CFAbsoluteTime fireDate = CFAbsoluteTimeGetCurrent() + interval;
// Create the timer
cfTimer = CFRunLoopTimerCreate(
Expand Down

0 comments on commit e9447a0

Please sign in to comment.