Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a task scheduler for background indexing and preparation #1208

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ let package = Package(
swiftSettings: [.enableExperimentalFeature("StrictConcurrency")]
),

// MARK: CAtomics
.target(
name: "CAtomics",
dependencies: []
),

// MARK: CSKTestSupport
.target(
name: "CSKTestSupport",
Expand Down Expand Up @@ -170,6 +176,7 @@ let package = Package(
name: "SKCore",
dependencies: [
"BuildServerProtocol",
"CAtomics",
"LanguageServerProtocol",
"LanguageServerProtocolJSONRPC",
"LSPLogging",
Expand Down
Empty file added Sources/CAtomics/CAtomics.c
Empty file.
2 changes: 2 additions & 0 deletions Sources/CAtomics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_library(CAtomics INTERFACE)
target_include_directories(CAtomics INTERFACE "include")
66 changes: 66 additions & 0 deletions Sources/CAtomics/include/CAtomics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

#ifndef SOURCEKITLSP_CATOMICS_H
#define SOURCEKITLSP_CATOMICS_H

#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>

// MARK: - AtomicBool

typedef struct {
_Atomic(bool) value;
} AtomicBool;

__attribute__((swift_name("AtomicBool.init(initialValue:)")))
static inline AtomicBool atomic_bool_create(bool initialValue) {
AtomicBool atomic;
atomic.value = initialValue;
return atomic;
}

__attribute__((swift_name("getter:AtomicBool.value(self:)")))
static inline bool atomic_bool_get(AtomicBool *atomic) {
return atomic->value;
}

__attribute__((swift_name("setter:AtomicBool.value(self:_:)")))
static inline void atomic_bool_set(AtomicBool *atomic, bool newValue) {
atomic->value = newValue;
}

// MARK: - AtomicUInt8

typedef struct {
_Atomic(uint8_t) value;
} AtomicUInt8;

__attribute__((swift_name("AtomicUInt8.init(initialValue:)")))
static inline AtomicUInt8 atomic_uint8_create(uint8_t initialValue) {
AtomicUInt8 atomic;
atomic.value = initialValue;
return atomic;
}

__attribute__((swift_name("getter:AtomicUInt8.value(self:)")))
static inline uint8_t atomic_uint8_get(AtomicUInt8 *atomic) {
return atomic->value;
}

__attribute__((swift_name("setter:AtomicUInt8.value(self:_:)")))
static inline void atomic_uint8_set(AtomicUInt8 *atomic, uint8_t newValue) {
atomic->value = newValue;
}

#endif // SOURCEKITLSP_CATOMICS_H
4 changes: 4 additions & 0 deletions Sources/CAtomics/include/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module CAtomics {
header "CAtomics.h"
export *
}
1 change: 1 addition & 0 deletions Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_subdirectory(BuildServerProtocol)
add_subdirectory(CAtomics)
add_subdirectory(Csourcekitd)
add_subdirectory(Diagnose)
add_subdirectory(LanguageServerProtocol)
Expand Down
2 changes: 2 additions & 0 deletions Sources/SKCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ add_library(SKCore STATIC
MainFilesProvider.swift
PathPrefixMapping.swift
SplitShellCommand.swift
TaskScheduler.swift
Toolchain.swift
ToolchainRegistry.swift
XCToolchainPlist.swift)
set_target_properties(SKCore PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
target_link_libraries(SKCore PUBLIC
BuildServerProtocol
CAtomics
LanguageServerProtocol
LanguageServerProtocolJSONRPC
LSPLogging
Expand Down
Loading