Skip to content

Simple implementation of SpinLockLib, using pimpl idiom

Notifications You must be signed in to change notification settings

avasyy/SpinLockLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SpinLock Library

  • The spinlock lib is implemented with Pimpl mechanism, so it doesn't expose the implementation details.

Build

  • To build everything you need to run this command
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build build

Install

  • To install the spinlock lib to /usr/local/ you need to use this command
sudo cmake --install build

FYI: You have to run with sudo as this path is under root ownership

Usage

Manual

If you want to compile some code from console you should use these commands:

g++ main.cpp -lspinlock -std=c++17 -Wl,-rpath,/usr/local/lib
./a.out

Makefile

If you want to use the Makefile to build your target you can use following examples

  • Makefile
CXX = g++
CXXFLAGS = -std=c++17 -I/usr/local/include
LDFLAGS = -L/usr/local/lib -lspinlock

# For runtime, embed rpath so no need to set env vars
LDFLAGS += -Wl,-rpath,/usr/local/lib

TARGET = target
SRC = main.cpp

all: $(TARGET)

$(TARGET): $(SRC)
	$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)

clean:
	rm -f $(TARGET)
  • Run the target
make
./target

CMakeLists

If you want to use the CMakeLists.txt to build your target you can use following examples

  • CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(Target VERSION 1.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(spinlock REQUIRED)

add_executable(target main.cpp)

set_target_properties(target PROPERTIES
    BUILD_WITH_INSTALL_RPATH TRUE
    INSTALL_RPATH "@loader_path/../lib;/usr/local/lib"
    INSTALL_RPATH_USE_LINK_PATH TRUE
)

target_link_libraries(target PRIVATE spinlock)
  • Run the target
cmake -S . -B build
cmake --build build
./build/target

About

Simple implementation of SpinLockLib, using pimpl idiom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published