How to use semaphores

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use semaphores

Boost - Build mailing list
Hi!

I can't get semaphores working (
http://www.boost.org/build/doc/html/jam/language.html#jam.language.variables.builtins.semaphores 
).

I have the following jamroot.jam:


import notfile ;

notfile foo : @sleep ;
notfile bar : @sleep ;
actions sleep {
     sleep 1
}
JAM_SEMAPHORE on foo bar = s ;


And I build this project with 'b2 -j2'.

I expect build to be complete in 2 seconds since targets 'foo' and 'bar'
are supposed to be serialized, but it completes just in one second, no
matter what.

Unfortunately, I haven't found any working examples of using
JAM_SEMAPHORE. The only ones I found were located deeply in boost.build
source files and specified serialized targets indirectly, like $(targets).

Could someone please provide an example of how to properly serialize
execution of two actions with boost.build?

_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: How to use semaphores

Boost - Build mailing list
AMDG

On 01/22/2018 08:20 AM, olan via Boost-build wrote:

> <snip>
> import notfile ;
>
> notfile foo : @sleep ;
> notfile bar : @sleep ;
> actions sleep {
>     sleep 1
> }
> JAM_SEMAPHORE on foo bar = s ;
>
> <snip>
>

JAM_SEMAPHORE needs to be set on the
jam targets, not the meta targets.

rule sleep ( targets * : sources * : properties * )
{
  # You should probably use a longer name than `s` to avoid clashes.
  JAM_SEMAPHORE on $(targets) = s ;
}

In Christ,
Steven Watanabe
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: How to use semaphores

Boost - Build mailing list
On 22.01.2018 19:51, Steven Watanabe via Boost-build wrote:
> JAM_SEMAPHORE needs to be set on the
> jam targets, not the meta targets.
>
> rule sleep ( targets * : sources * : properties * )
> {
>    # You should probably use a longer name than `s` to avoid clashes.
>    JAM_SEMAPHORE on $(targets) = s ;
> }
Thanks! Adding this to jamroot.jam solves the problem.
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build