Skip to content

Commit 6036c33

Browse files
committed
issues fixes
1 parent 169b556 commit 6036c33

8 files changed

Lines changed: 27 additions & 16 deletions

src/modules/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function(add_jam_module NAME)
7070

7171
# Set C++ standard
7272
target_compile_features(${MODULE} PRIVATE
73-
cxx_std_20
73+
cxx_std_23
7474
)
7575

7676
add_dependencies(all_modules ${MODULE})

src/se/impl/async_dispatcher_impl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace jam::se {
1414

1515
template <uint32_t kCount, uint32_t kPoolSize>
16-
class AsyncDispatcher final : public IDispatcher {
16+
class AsyncDispatcher final : public Dispatcher {
1717
public:
1818
// Disable copying
1919
AsyncDispatcher(const AsyncDispatcher &) = delete;
@@ -27,7 +27,7 @@ namespace jam::se {
2727
static constexpr uint32_t kPoolThreadsCount = kPoolSize;
2828

2929
private:
30-
using Parent = IDispatcher;
30+
using Parent = Dispatcher;
3131

3232
struct SchedulerContext {
3333
/// Scheduler to execute tasks

src/se/impl/dispatcher.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@
1313

1414
namespace jam::se {
1515

16-
struct IDispatcher {
16+
/**
17+
* Interface for task dispatchers that handle execution across different threads
18+
*/
19+
struct Dispatcher {
1720
using Tid = uint32_t;
1821
using Task = IScheduler::Task;
1922
using Predicate = IScheduler::Predicate;
2023

2124
static constexpr Tid kExecuteInPool = std::numeric_limits<Tid>::max();
2225

23-
virtual ~IDispatcher() = default;
26+
virtual ~Dispatcher() = default;
2427

2528
virtual std::optional<Tid> bind(std::shared_ptr<IScheduler> scheduler) = 0;
2629
virtual bool unbind(Tid tid) = 0;

src/se/impl/scheduler_impl.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace jam::se {
5151
std::thread::id id_;
5252

5353
private:
54-
inline void checkLocked() {
54+
void checkLocked() {
5555
/// Need to check that we are locked in debug.
5656
assert(!tasks_cs_.try_lock());
5757
}
@@ -104,6 +104,7 @@ namespace jam::se {
104104

105105
return std::chrono::microseconds(0ull);
106106
}
107+
// Default timeout when no tasks are pending - prevents busy waiting
107108
return std::chrono::minutes(10ull);
108109
}
109110

@@ -147,6 +148,7 @@ namespace jam::se {
147148
}
148149
}
149150
} catch (...) {
151+
// Ignore exceptions during task execution to prevent scheduler crash
150152
}
151153
} else {
152154
event_.wait(untilFirst());

src/se/impl/subscription_engine.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
namespace jam::se {
1919

20+
/**
21+
* Interface for objects that can be disposed/cleaned up
22+
*/
2023
struct IDisposable {
2124
virtual void dispose() = 0;
2225
};

src/se/impl/subscription_manager.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
#include "subscriber.hpp"
1818
#include "subscription_engine.hpp"
1919

20+
// Cross-platform function name macro for subscription hashing
21+
#ifdef _WIN32
22+
#define FUNCTION_NAME __FUNCSIG__
23+
#else
24+
#define FUNCTION_NAME __PRETTY_FUNCTION__
25+
#endif
26+
2027
namespace jam::se {
2128

2229
/**
@@ -38,7 +45,7 @@ namespace jam::se {
3845
SubscriptionManager(SubscriptionManager &&) = delete;
3946
SubscriptionManager &operator=(SubscriptionManager &&) = delete;
4047

41-
using Dispatcher = jam::se::IDispatcher;
48+
using Dispatcher = jam::se::Dispatcher;
4249

4350
private:
4451
using EngineHash = uint64_t;
@@ -56,11 +63,7 @@ namespace jam::se {
5663
private:
5764
template <typename... Args>
5865
static constexpr EngineHash getSubscriptionHash() {
59-
#ifdef _WIN32
60-
constexpr EngineHash value = CT_MURMUR2(__FUNCSIG__);
61-
#else //_WIN32
62-
constexpr EngineHash value = CT_MURMUR2(__PRETTY_FUNCTION__);
63-
#endif //_WIN32
66+
constexpr EngineHash value = CT_MURMUR2(FUNCTION_NAME);
6467
return value;
6568
}
6669

src/se/impl/sync_dispatcher_impl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
namespace jam::se {
1313

1414
template <uint32_t kCount, uint32_t kPoolSize>
15-
class SyncDispatcher final : public IDispatcher {
15+
class SyncDispatcher final : public Dispatcher {
1616
private:
17-
using Parent = IDispatcher;
17+
using Parent = Dispatcher;
1818

1919
public:
2020
// Disable copying

src/se/subscription_fwd.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace jam {
2424
static constexpr uint32_t kThreadPoolSize = 3u;
2525

2626
namespace se {
27-
struct IDispatcher;
27+
struct Dispatcher;
2828

2929
template <uint32_t kHandlersCount, uint32_t kPoolSize>
3030
class SubscriptionManager;
@@ -36,7 +36,7 @@ namespace jam {
3636
class SubscriberImpl;
3737
} // namespace se
3838

39-
using Dispatcher = se::IDispatcher;
39+
using Dispatcher = se::Dispatcher;
4040
using Subscription =
4141
se::SubscriptionManager<SubscriptionEngineHandlers::kTotalCount,
4242
kThreadPoolSize>;

0 commit comments

Comments
 (0)