# -*- 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=[
        'admission_context',
    ],
    LIBDEPS_PRIVATE=[
        '$BUILD_DIR/mongo/db/server_base',
        '$BUILD_DIR/mongo/db/service_context',
        '$BUILD_DIR/third_party/shim_boost',
    ],
)

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

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_non_d',
        '$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/admission/execution_admission_context',
        '$BUILD_DIR/mongo/db/concurrency/lock_manager',
        '$BUILD_DIR/mongo/db/service_context_non_d',
        'ticketholder',
    ],
)

env.Benchmark(
    target='lock_free_read_list_bm',
    source=[
        'lock_free_read_list_bm.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/util/processinfo',
    ],
)

env.CppUnitTest(
    target='lock_free_read_list_test',
    source=[
        'lock_free_read_list_test.cpp',
    ],
    LIBDEPS=[],
)
