bgjobsupport.pro

来自「Visual Prolog 7.1的一些学习资料,希望对您有用」· PRO 代码 · 共 47 行

PRO
47
字号
/*****************************************************************************

                        Copyright (c) Prolog Development Center A/S

******************************************************************************/

implement bgJobSupport
    open core

    constants
        className = "background/backgroundSupport/bgJobSupport".
        classVersion = "$JustDate: 2004-10-02 $$Revision: 1 $".

    clauses
        startJob(Job) = startJob(Job, multiThread_native::thread_priority_lowest).

    class predicates
        startJob : (bgJob Job, multiThread_native::threadPriority Priority) -> thread JobThread.

    clauses
        startJob(Job, Priority) = Thread :-
            J = bgJobSupport::new(Job),
            Thread = thread::createSuspended(J:run),
            Thread:setPriority(Priority),
            _ = Thread:resume().

    facts
        job : bgJob.
    clauses
        new(Job) :-
            job := Job.

    clauses
        run() :-
            job:job(),
            bgSynchronizer::postResult(job).

    clauses
        makeRunnablePersistent(Runnable) = uncheckedConvert(runnable, Mem) :-
            Size = 8,
            Mem = memory::allocHeap(Size),
            memory::move(Mem, uncheckedConvert(pointer, Runnable), Size).

    clauses
        classInfo(className, classVersion).
end implement bgJobSupport

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?