<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Approximatrix Forums — Appgraphics mutex]]></title>
		<link>https://forums.approximatrix.com/viewtopic.php?id=816</link>
		<atom:link href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=816&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Appgraphics mutex.]]></description>
		<lastBuildDate>Mon, 21 Jun 2021 13:54:32 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Appgraphics mutex]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3767#p3767</link>
			<description><![CDATA[<p>Jeff,<br /> thank you. You are right, my mistake.<br />&nbsp; Petr</p>]]></description>
			<author><![CDATA[null@example.com (pm1a)]]></author>
			<pubDate>Mon, 21 Jun 2021 13:54:32 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3767#p3767</guid>
		</item>
		<item>
			<title><![CDATA[Re: Appgraphics mutex]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3766#p3766</link>
			<description><![CDATA[<p>Petr,</p><p>I haven&#039;t tried your program yet, but I do notice that, in your main loop, you lock the mutex, but you only unlock it if <em>skoncit</em> is <em>.true.</em>.&nbsp; I think you want to:</p><div class="codebox"><pre><code>        if ( lockmutex(mut_main) ) then
          if ( skoncit ) then
            print *, &quot;jdu koncit&quot;
            call unlockmutex(mut_main)
            exit mainloop
          end if
          call unlockmutex(mut_main)
        end if</code></pre></div><p>Does that fix the issue?</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Mon, 21 Jun 2021 11:20:30 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3766#p3766</guid>
		</item>
		<item>
			<title><![CDATA[Appgraphics mutex]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3765#p3765</link>
			<description><![CDATA[<p>Can you give me a little more explanation how mutexes works with Appgraphics? <br />I wish keep main program computing and comunicate by shared variables with interface. To protect them I create mutex by call of createmutex() . Inside the main program I&#039;m able to lock it and unlock it. But if I try to do same inside callback procedure konec I never get lock. For now I just comment out few lines of code but it is unsatisfactory. <br /> Could you help me, please?</p><p>&nbsp; Thanks <br />&nbsp; &nbsp; &nbsp;Petr</p><p>module apptools<br />&nbsp; &nbsp; use appgraphics<br />&nbsp; &nbsp; integer :: myscreen<br />&nbsp; &nbsp; integer :: menuroot_id !&gt; root menu id<br />&nbsp; &nbsp; integer :: menu_close<br />&nbsp; &nbsp; integer :: menu_actions<br />&nbsp; &nbsp; integer :: menu_help<br />&nbsp; &nbsp; integer :: mclose_act<br />&nbsp; &nbsp; integer :: mut_main<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; logical :: skoncit</p><br /><p>contains<br />&nbsp; subroutine konec()<br />&nbsp; &nbsp; print *, &quot;koncime&quot;, mut_main<br />&nbsp; &nbsp; !if ( lockmutex(mut_main, -1) ) then<br />&nbsp; &nbsp; &nbsp; &nbsp;skoncit = .true.<br />&nbsp; &nbsp; &nbsp; &nbsp;print *, &quot;oznaceno&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp;!call unlockmutex(mut_main)<br />&nbsp; &nbsp; !end if<br />&nbsp; end subroutine konec<br />end module apptools</p><br /><p>program main<br />use appgraphics<br />use apptools<br />implicit none</p><p>&nbsp; &nbsp; real(16) :: s,i<br />&nbsp; &nbsp; integer :: inisizex, inisizey<br />&nbsp; &nbsp; character(65) :: repstr<br />&nbsp; &nbsp; integer :: cnt<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; inisizex = 800 <br />&nbsp; &nbsp; inisizey = 600<br />&nbsp; &nbsp; skoncit = .false.<br />&nbsp; &nbsp; mut_main = createmutex()<br />&nbsp; &nbsp; print *, mut_main<br />&nbsp; &nbsp; print *, lockmutex(mut_main)<br />&nbsp; &nbsp; call unlockmutex(mut_main)<br />&nbsp; &nbsp; myscreen = initwindow(inisizex, inisizey, closeflag=.false.)<br />&nbsp; &nbsp; menuroot_id = addmenu(&quot;&quot;)<br />&nbsp; &nbsp; print *, menuroot_id<br />&nbsp; &nbsp; menu_actions = addmenu(&quot;Activity&quot;,menuroot_id)<br />&nbsp; &nbsp; print *, menu_actions<br />&nbsp; &nbsp; menu_close&nbsp; &nbsp;= addmenu(&quot;Konec&quot;, menuroot_id)<br />&nbsp; &nbsp; print *, menu_close<br />&nbsp; &nbsp; menu_help = addmenu(&quot;Napoveda&quot;, menuroot_id)<br />&nbsp; &nbsp; print *, menu_help<br />&nbsp; &nbsp; mclose_act = addmenuitem(&quot;Ukoncit program,&quot;,menu_close,konec)<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; !call loop()<br />&nbsp; &nbsp; s = 0<br />&nbsp; &nbsp; i = 0<br />&nbsp; &nbsp; cnt = 0<br />&nbsp; &nbsp;mainloop : do<br />&nbsp; &nbsp; &nbsp; i = i + 1<br />&nbsp; &nbsp; &nbsp; s = s + 1/i<br />&nbsp; &nbsp; &nbsp; cnt = cnt + 1<br />&nbsp; &nbsp; &nbsp; !print *, i,s<br />&nbsp; &nbsp; &nbsp; if ( isvalidwindow(myscreen) .and. (cnt == 10000) ) then <br />&nbsp; &nbsp; &nbsp; &nbsp; cnt = 0<br />&nbsp; &nbsp; &nbsp; &nbsp; write(repstr,&quot;(f15.0,2f25.17)&quot;) i,s,s-log(i)<br />&nbsp; &nbsp; &nbsp; &nbsp; call outtextxy(50,200,repstr);<br />&nbsp; &nbsp; &nbsp; &nbsp; if ( lockmutex(mut_main) ) then<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ( skoncit ) then<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print *, &quot;jdu koncit&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; call unlockmutex(mut_main)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit mainloop<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end if<br />&nbsp; &nbsp; &nbsp; &nbsp; end if<br />&nbsp; &nbsp; &nbsp; end if<br />&nbsp; &nbsp; end do mainloop<br />&nbsp; &nbsp; print *, &quot;Chci zavrit okno5&quot;<br />&nbsp; &nbsp; call closewindow(myscreen)</p><p>end program main</p>]]></description>
			<author><![CDATA[null@example.com (pm1a)]]></author>
			<pubDate>Mon, 21 Jun 2021 09:48:13 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3765#p3765</guid>
		</item>
	</channel>
</rss>
