Re: Synchronization with system:make-directory
Thanks Ladislav. But what I do is simply a build script and that
directory thing works so far.
2016-08-03 18:48 GMT+03:00, Ladislav Koščo <laci.kosco@gmail.com>:
> Hi,
>
> depending on what you are trying to achieve, it might be an overkill, but
> have you considered those two application talking to each other? Like
> zero-mq, or lparallel (actualy maybe lfarm - https://lparallel.org/
> https://github.com/lmj/lfarm/blob/master/README.md)
>
> alternativelly, you can try to listen on specific port (and it should allow
> only one instance of app to listen on port) and then use something like
> zeroMQ to distribute messages (and effectively you can end up with one
> really small instance that will orchestrate others).
>
> in past, i have had many chances to see locking as pain in the ass, that
> can be resolved by queuing, and the "locking" is replaced by trying to get
> message, and only one worker succeeds.
>
>
> good luck
>
> laci
>
> On Thu, Jul 7, 2016 at 10:17 PM, 73budden . <budden73@gmail.com> wrote:
>
>>
>> Thanks Martin!
>>
>> 2016-07-06 15:00 GMT+03:00, Martin Simmons <martin@lispworks.com>:
>> >
>> >>>>>> On Wed, 6 Jul 2016 00:13:17 +0300, 73budden said:
>> >>
>> >> Hi!
>> >>
>> >> I was fighting to synchronize two instances of LW-based applications
>> >> under Windows so that they would do some kind of activity sequentially
>> >> rather than in parallel.
>> >>
>> >> I tried to create temporary "lock files", but I found that open seem
>> >> to be non-atomic. This reason or another, I could not make it work.
>> >>
>> >> But I found there is an undocumented system:make-directory. I used the
>> >> following "mutex" imitation: "lock" function tries to make a
>> >> directory. If it succeedes we agree that it acquired a "mutex". If it
>> >> fails we assume some other process is holding the lock.
>> >>
>> >> To unlock, we just delete-directory.
>> >>
>> >> The question to LW team is the following: is it safe to use this
>> >> technique under Windows? If yes, I think it would worth documenting.
>> >
>> > The current implementation of system:make-directory is an almost direct
>> > call
>> > to the Win32 function CreateDirectory. That is probably atomic, but I
>> > wouldn't like to guarantee it.
>> >
>> >
>> >> Otherwise I would need either to create FLI bindings to CreateMutex
>> >> and its neighbours or find some other approaches to achieve a
>> >> synchronization.
>> >
>> > I think CreateMutex is the safest approach.
>> >
>> > --
>> > Martin Simmons
>> > LispWorks Ltd
>> > http://www.lispworks.com/
>> >
>> > _______________________________________________
>> > Lisp Hug - the mailing list for LispWorks users
>> > lisp-hug@lispworks.com
>> > http://www.lispworks.com/support/lisp-hug.html
>> >
>> >
>>
>> _______________________________________________
>> Lisp Hug - the mailing list for LispWorks users
>> lisp-hug@lispworks.com
>> http://www.lispworks.com/support/lisp-hug.html
>>
>>
>
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html