Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Blocking function calls into a goroutine
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Maarten Koopmans  
View profile  
 More options Sep 11 2012, 5:35 am
From: Maarten Koopmans <maarten.koopm...@gmail.com>
Date: Tue, 11 Sep 2012 02:35:52 -0700 (PDT)
Local: Tues, Sep 11 2012 5:35 am
Subject: Re: [go-nuts] Blocking function calls into a goroutine

Tahir,

I'm new to go bit have done a lot of "messaging" (e.g. actors in Scala).

I *think* you need to change your thinking on this: forget about blocking
function call semantics. What you want (I think) is to protect one or more
resources, i.e. give only "atomic" access?

If that's the case then your solution would be:

1) a unique goroutine that reads from a channel and then performs logic
atomically (update the webcounter)
2) concurrent clients that write to the channel (trigger an update)

If the clients needs a return value it can pass in a channel in the request
which is unique to that particular client. This will have the effect of
blocking on the client goroutine as well (when it waits for the results to
come back).

What helps me with Go is if I think of goroutines of logic on top of queues
(channels).

--Maarten

Op dinsdag 11 september 2012 09:00:19 UTC+2 schreef Tahir Hashmi het
volgende:

> On Tuesday, September 11, 2012 11:57:43 AM UTC+5:30, Rémy Oudompheng wrote:

>> This is surprising. Why wasn't it working ?

>> Rémy.

> One of the reasons why this was not working was because I was writing the
> functions that need to be synchronised as:

> func foo {
>     mutex.Lock()
>     defer mutex.Unlock()

>     // do whatever else
> }

> The coarse-grained locking meant that I had some conditions under which
> foo() would call bar(), which too needed to be synchronised on the same
> mutex, leading to a deadlock. I did move the lock/unlock bits to only wrap
> the critical sections, but the application was still freezing under high
> load. I later decided to extract all the shared state into its own handlers
> and use channels to communicate with the handlers so that I shared state by
> communicating, rather than communicating through shared state.

> --
> Tahir Hashmi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.