# -*- mode: python -*-

Import("env")

env = env.Clone()

env.Library(
    target='thread_pool',
    source=[
        'thread_pool.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/base',
    ],
)

env.Library(
    target='thread_pool_test_fixture',
    source=['thread_pool_test_common.cpp', 'thread_pool_test_fixture.cpp'],
    LIBDEPS_PRIVATE=[
        '$BUILD_DIR/mongo/unittest/unittest',
    ],
)

env.Library(
    target='ticketholder',
    source=[
        'priority_ticketholder.cpp' if env.TargetOSIs('linux') else [],
        'semaphore_ticketholder.cpp',
        'ticket_pool.cpp' if env.TargetOSIs('linux') else [],
        'ticketholder.cpp',
    ],
    LIBDEPS_PRIVATE=[
        '$BUILD_DIR/mongo/base',
        '$BUILD_DIR/mongo/db/service_context',
        '$BUILD_DIR/mongo/db/storage/concurrency_adjustment_parameters',
        # TODO (SERVER-67104): Remove this dependency.
        '$BUILD_DIR/mongo/db/storage/storage_engine_feature_flags',
        '$BUILD_DIR/third_party/shim_boost',
        'admission_context',
    ],
)

env.Library(target='admission_context', source=['admission_context.cpp'],
            LIBDEPS=['$BUILD_DIR/mongo/base'])

env.Library(
    target='spin_lock',
    source=[
        "spin_lock.cpp",
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/base',
    ],
)

env.CppUnitTest(
    target='util_concurrency_test',
    source=[
        'priority_ticketholder_test.cpp' if env.TargetOSIs('linux') else [],
        'semaphore_ticketholder_test.cpp',
        'spin_lock_test.cpp',
        'thread_pool_test.cpp',
        'ticketholder_test_fixture.cpp',
        'ticket_pool_test.cpp' if env.TargetOSIs('linux') else [],
        'with_lock_test.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/auth/authmocks',
        '$BUILD_DIR/mongo/db/service_context_test_fixture',
        'spin_lock',
        'thread_pool',
        'thread_pool_test_fixture',
        'ticketholder',
    ],
)

env.Benchmark(
    target='ticketholder_bm',
    source=[
        'ticketholder_bm.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/service_context',
        'ticketholder',
    ],
)
